internal/lsp/source: fix bug introduced by CL 246757

CL 246757 resulted in an infinite loop because the value of "o" is
never updated.

Change-Id: I79cf265349838de19089c4468128c565a9a3cda3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/247182
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Baum <joshbaum@google.com>
This commit is contained in:
Rebecca Stambler 2020-08-06 13:06:53 -04:00
parent 90696ccdc6
commit ee49e490f2
1 changed files with 3 additions and 3 deletions

View File

@ -476,13 +476,13 @@ func adjustRangeForWhitespace(rng span.Range, tok *token.File, content []byte) s
}
rng.Start = tok.Pos(offset)
// Move backwards to find a non-whitespace character.
offset = tok.Offset(rng.End)
for o := offset - 1; 0 <= o && o < len(content); {
for o := offset - 1; 0 <= o && o < len(content); o-- {
if !unicode.IsSpace(rune(content[o])) {
break
}
// Move backwards one byte to find a non-whitespace character.
offset -= 1
offset = o
}
rng.End = tok.Pos(offset)
return rng