Skip to content

Commit

Permalink
internal/lsp/source: fix bug introduced by CL 246757
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stamblerre committed Aug 6, 2020
1 parent 90696cc commit ee49e49
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/lsp/source/extract.go
Expand Up @@ -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
Expand Down

0 comments on commit ee49e49

Please sign in to comment.