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

Cursor jumps to component body instead of definition on first jump #1

Open
gabrielvincent opened this issue Sep 8, 2024 · 6 comments

Comments

@gabrielvincent
Copy link

gabrielvincent commented Sep 8, 2024

The very first jump lands on the component body rather than on its definition, but subsequent jumps work as intended. See how when I go to definition from a @components.Layout instance, it first lands on the <body> tag the first time.

templ-goto.mov
@gabrielvincent gabrielvincent changed the title Cursor jumpt to component body instead of definition on first jump Cursor jumps to component body instead of definition on first jump Sep 8, 2024
@catgoose
Copy link
Owner

catgoose commented Sep 8, 2024

Could you provide a repo I could pull down to test against?

Thanks.

@catgoose
Copy link
Owner

catgoose commented Sep 8, 2024

Oh I see. I only tested this using go files not from templ. I'll look at this later today.

@gabrielvincent
Copy link
Author

Could you provide a repo I could pull down to test against?

Thanks.

Of course, here you go: https://github.com/gabrielvincent/templ-goto-definition-initial-gtd-bug

How to reproduce the error:

  1. vim ./path/to/templ-goto-definition-initial-gtd-bug/.
  2. Open main.templ.
  3. Place the cursor over Layout().
  4. Hit gd keybinding.
  5. See the error:
   Error  19:11:32 msg_show.lua_error Error executing vim.schedule lua callback: ...ar/neovim/0.10.1/share/nvim/runtime/lua/vim/lsp/util.lua:1914: index out of range
stack traceback:
	[C]: in function '_str_byteindex_enc'
	...ar/neovim/0.10.1/share/nvim/runtime/lua/vim/lsp/util.lua:1914: in function 'locations_to_items'
	...nvim/lazy/telescope.nvim/lua/telescope/builtin/__lsp.lua:197: in function 'handler'
	.../neovim/0.10.1/share/nvim/runtime/lua/vim/lsp/client.lua:687: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

How to get gtd action to work from the start:

  1. vim ./path/to/templ-goto-definition-initial-gtd-bug/.
  2. Open layouts/layouts.templ
  3. Open main.templ.
  4. Place the cursor over Layout().
  5. Hit gd keybinding.
  6. Land on the definition correctly.

The problem only occurs when the destination buffer hasn't been opened yet.

@catgoose
Copy link
Owner

catgoose commented Sep 8, 2024

This looks exactly like a-h/templ#893 which supposedly was fixed in the last release of templ, but I am getting the same error you are in .10.1 and nightly.

This is an issue with templ LSP it seems so I will open an issue with templ

@catgoose
Copy link
Owner

This should be fixed when templ makes a new release. See: a-h/templ#911

@catgoose
Copy link
Owner

@gabrielvincent can you see if this is working with latest templ version?

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

No branches or pull requests

2 participants