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

Wrong line number in error messages (off by 1) #1051

Closed
MaxLap opened this issue Jan 21, 2025 · 1 comment
Closed

Wrong line number in error messages (off by 1) #1051

MaxLap opened this issue Jan 21, 2025 · 1 comment

Comments

@MaxLap
Copy link

MaxLap commented Jan 21, 2025

Describe the bug
Error message when parsing is sometime off by one for the line.
For the following snippet:

package templates

templ TestResult() {
	<helloworld (required)>'
}

Running templ generate

Fails with the following: malformed open element: line 3, col 13. But that is straight in the middle of the "TestResult" name.
The actual problem (and as highlighted by the LSP), is on line 4 at col 13.

To Reproduce
Make a file with the provided error case, run templ generate.

templ info output
(✓) os [ goos=linux goarch=amd64 ]
(✓) go [ location=/usr/local/go/bin/go version=go version go1.23.4 linux/amd64 ]
(✓) gopls [ location=/home/max/go/bin/gopls version=golang.org/x/tools/gopls v0.17.1 ]
(✓) templ [ location=/home/max/go/bin/templ version=v0.3.819 ]

Desktop (please complete the following information):

  • OS: WSL
  • templ CLI version v0.3.819
  • Go version go version go1.23.4 linux/amd64
  • gopls version: golang.org/x/tools/gopls v0.17.1
@a-h a-h closed this as completed in 45f4c46 Jan 22, 2025
@a-h
Copy link
Owner

a-h commented Jan 22, 2025

Thanks, the line number is zero-based, which matches the LSP standard, but humans should probably see 1-based to match what's displayed in the text editor.

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