Skip to content

Commit 4e58f8f

Browse files
committed
internal/lsp: handle out of range panic in template parsing
Fixes golang/vscode-go#1548 Change-Id: I95911a417cecc514151e75a60253ef119803885e Reviewed-on: https://go-review.googlesource.com/c/tools/+/326089 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org>
1 parent 716319f commit 4e58f8f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/lsp/template/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func parseBuffer(buf []byte) *Parsed {
8686
ans := &Parsed{
8787
buf: buf,
8888
check: -1,
89+
nls: []int{-1},
8990
}
9091
if len(buf) == 0 {
9192
ans.ParseErr = errors.New("empty buffer")
@@ -103,7 +104,6 @@ func parseBuffer(buf []byte) *Parsed {
103104
}
104105
// at the cost of complexity we could fold this into the allAscii loop
105106
ans.lines = bytes.Split(buf, []byte{'\n'})
106-
ans.nls = []int{-1}
107107
for i, p := range ans.buf {
108108
if p == '\n' {
109109
ans.nls = append(ans.nls, i)

0 commit comments

Comments
 (0)