Skip to content

Commit

Permalink
fix(lsp): add missing nil check in CodeAction, fixes #771
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Jun 2, 2024
1 parent 108500b commit 73474f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.709
0.2.717
12 changes: 7 additions & 5 deletions cmd/templ/lspcmd/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,14 @@ func (p *Server) CodeAction(ctx context.Context, params *lsp.CodeActionParams) (
r.Diagnostics[di].Range = p.convertGoRangeToTemplRange(templURI, r.Diagnostics[di].Range)
}
// Rewrite the DocumentChanges.
for dci := 0; dci < len(r.Edit.DocumentChanges); dci++ {
dc := r.Edit.DocumentChanges[0]
for ei := 0; ei < len(dc.Edits); ei++ {
dc.Edits[ei].Range = p.convertGoRangeToTemplRange(templURI, dc.Edits[ei].Range)
if r.Edit != nil {
for dci := 0; dci < len(r.Edit.DocumentChanges); dci++ {
dc := r.Edit.DocumentChanges[0]
for ei := 0; ei < len(dc.Edits); ei++ {
dc.Edits[ei].Range = p.convertGoRangeToTemplRange(templURI, dc.Edits[ei].Range)
}
dc.TextDocument.URI = templURI
}
dc.TextDocument.URI = templURI
}
result[i] = r
}
Expand Down

0 comments on commit 73474f6

Please sign in to comment.