templ icon indicating copy to clipboard operation
templ copied to clipboard

bug(lsp): diagnostics error on Windows due to URI encoding

Open efsant0s opened this issue 1 year ago • 1 comments

Describe the bug While using VSCode, using the latest version of templ and Gopls, Windows URI sent by DidOpen is different than the one expected by Client.PublishDiagnostics

To Reproduce Just open VSCode templ on windows enviroment.

Expected behavior Templ is not going to work, and in the logs you can see this: {

"level":"info",

"ts":"2024-08-30T11:29:53+01:00",

"caller":"proxy/server.go:648",

"msg":"client -> server: DidOpen",

"uri":"file:///c%3A/Projects/go-starmt-app/component/button/button.sub.component.templ"

}{

"level":"error",

"ts":"2024-08-30T11:29:53+01:00",

"caller":"proxy/client.go:65",

"msg":"unable to complete because the sourcemap for the URI doesn't exist in the cache",

"uri":"file:///C:/Projects/go-starmt-app/component/button/button.sub.component.templ",

"stacktrace":"github.com/a-h/templ/cmd/templ/lspcmd/proxy.Client.PublishDiagnostics\n\tC:/Users/juans/go/pkg/mod/github.com/a-h/[email protected]/cmd/templ/lspcmd/proxy/client.go:65\ngithub.com/a-h/protocol.clientDispatch\n\tC:/Users/juans/go/pkg/mod/github.com/a-h/[email protected]/client.go:102\ngithub.com/a-h/protocol.NewClient.ClientHandler.func1\n\tC:/Users/juans/go/pkg/mod/github.com/a-h/[email protected]/client.go:36\ngithub.com/a-h/protocol.Handlers.ReplyHandler.func1\n\tC:/Users/juans/go/pkg/mod/go.lsp.dev/[email protected]/handler.go:35\ngithub.com/a-h/protocol.Handlers.AsyncHandler.func2.2\n\tC:/Users/juans/go/pkg/mod/go.lsp.dev/[email protected]/handler.go:114"

}

As you can see the uri stored with DidOpen is

"uri":"file:///c%3A/Projects/go-starmt-app/component/button/button.sub.component.templ" and the requested one is "uri":"file:///C:/Projects/go-starmt-app/component/button/button.sub.component.templ",

efsant0s avatar Aug 30 '24 13:08 efsant0s

Hi, how do you reproduce this issue? Does it happen if you open any templ file?

Could you make a video and provide the full set of logs?

The URI file:///C:/Projects/go-starmt-app/component/button/button.sub.component.templ is invalid, since it contains the ":" character, but I don't know where that is URI is coming from - e.g. whether the diagnostic is being generated by gopls or templ, or whether VS Code is doing something incorrect.

I don't have a Windows computer to test on, so will not be able to make progress on this without additional logs, troubleshooting etc.

a-h avatar Aug 31 '24 11:08 a-h

No further info provided, can't reproduce.

a-h avatar Dec 28 '24 14:12 a-h