Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lsp): handle URI in item_to_location #3144

Merged
merged 2 commits into from
May 29, 2024

Conversation

lawrenceho
Copy link
Contributor

@lawrenceho lawrenceho commented May 29, 2024

Description

Following up on my comment in #3137 regarding the broken jump to Java classes such as java.lang.String because the JDT URI is not a file name. With item.filename being jdt:https://contents/java.base/java.lang/String.class..., the call vim.uri_from_fname(item.filename) in item_to_location would convert the JDT URI into an invalid URI by adding file:https:// in front of jdt:https:// and encode the already encoded URI again. The jump would fail as a result.

This is an attempt to fix the issue by applying filename to URI transformation only if item.filename is not a URI.

Error message:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1136: Cursor position outside buffer
stack traceback:
	[C]: in function 'nvim_win_set_cursor'
	/usr/share/nvim/runtime/lua/vim/lsp/util.lua:1136: in function 'jump_to_location'
	...nvim/lazy/telescope.nvim/lua/telescope/builtin/__lsp.lua:197: in function 'handler'
	/usr/share/nvim/runtime/lua/vim/lsp/client.lua:685: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

  • Test a jump to java.lang.String (JDT URI handled by nvim-jdtls)
  • Test a jump to normal Java source file in workspace
  • Test a jump to normal Lua source file in workspace

Configuration:

  • Neovim version (nvim --version):
    NVIM v0.10.0
    Build type: RelWithDebInfo
    LuaJIT 2.1.1707061634

  • Operating system and version:
    Linux (Fedora 40)

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

@Conni2461
Copy link
Member

does everything still work, i sadly cant test this because i dont use jdt? if yes i am going to merge, thanks for the fix :)

@lawrenceho
Copy link
Contributor Author

does everything still work, i sadly cant test this because i dont use jdt? if yes i am going to merge, thanks for the fix :)

Yes, it works fine with the latest change, thanks!

@Conni2461 Conni2461 merged commit dfa230b into nvim-telescope:master May 29, 2024
12 checks passed
@Conni2461
Copy link
Member

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants