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

Document highlight on vscode behaves strangely #283

Closed
ross96D opened this issue Nov 4, 2023 · 1 comment
Closed

Document highlight on vscode behaves strangely #283

ross96D opened this issue Nov 4, 2023 · 1 comment

Comments

@ross96D
Copy link
Contributor

ross96D commented Nov 4, 2023

When i put the cursor starts highlighting random places. Like on the images below

templ_Highlighting_issues_3


templ_Highlighting_issues_2


I did this on an html file and almost never highlight. The one that i found was when i put the cursor on a div and it highlights the div and the closing div. Like below
image

@a-h a-h closed this as completed in fe52296 Nov 12, 2023
@a-h
Copy link
Owner

a-h commented Nov 12, 2023

Hi @ross96D - thanks for raising this. The issue was that templ proxies LSP requests through to gopls in order to get results from the generated Go code. I did a talk about how it works at Gophercon UK this year.

In this case, there's no sensible mapping between things you're highlighting in VS Code, and the underlying Go code.

Screenshot 2023-11-12 at 15 59 11

There's a web server option in the templ LSP that shows you the underlying mapping. In this case, by adding to the logs, and looking at the view, I could see that when I was highlighting something in VS Code, it was sending it through to the templ LSP, and that was highlighting the positions of various bits of underlying Go code, so it looks totally random!

Screenshot 2023-11-12 at 16 04 15

I think the most sensible thing to do here is to not return any highlights from templ. Later on, if we want, we could implement some templ specific highlighting, but since tokens aren't often repeated, it's probably not very useful in templ.

No change is needed in the VS Code plugin, it's just a change to the templ CLI which runs the LSP.

Thanks again!

ross96D pushed a commit to ross96D/templ that referenced this issue Nov 14, 2023
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