diff --git a/.version b/.version index 8e6de6518..0cbceb828 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.2.738 \ No newline at end of file +0.2.742 \ No newline at end of file diff --git a/cmd/templ/lspcmd/proxy/server.go b/cmd/templ/lspcmd/proxy/server.go index c3070d48a..e6f24b0ae 100644 --- a/cmd/templ/lspcmd/proxy/server.go +++ b/cmd/templ/lspcmd/proxy/server.go @@ -393,6 +393,16 @@ func (p *Server) Completion(ctx context.Context, params *lsp.CompletionParams) ( if !ok { return nil, nil } + + // Ensure that Go source is available. + gosrc := strings.Split(p.GoSource[string(templURI)], "\n") + if len(gosrc)-1 < int(params.TextDocumentPositionParams.Position.Line) { + return nil, nil + } + if len(gosrc[params.TextDocumentPositionParams.Position.Line])-1 < int(params.TextDocumentPositionParams.Position.Character) { + return nil, nil + } + // Call the target. result, err = p.Target.Completion(ctx, params) if err != nil {