mirror of https://github.com/golang/go.git
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>
This commit is contained in:
parent
716319fe59
commit
4e58f8f09d
|
|
@ -86,6 +86,7 @@ func parseBuffer(buf []byte) *Parsed {
|
|||
ans := &Parsed{
|
||||
buf: buf,
|
||||
check: -1,
|
||||
nls: []int{-1},
|
||||
}
|
||||
if len(buf) == 0 {
|
||||
ans.ParseErr = errors.New("empty buffer")
|
||||
|
|
@ -103,7 +104,6 @@ func parseBuffer(buf []byte) *Parsed {
|
|||
}
|
||||
// at the cost of complexity we could fold this into the allAscii loop
|
||||
ans.lines = bytes.Split(buf, []byte{'\n'})
|
||||
ans.nls = []int{-1}
|
||||
for i, p := range ans.buf {
|
||||
if p == '\n' {
|
||||
ans.nls = append(ans.nls, i)
|
||||
|
|
|
|||
Loading…
Reference in New Issue