internal/span: fix utf16 column when span is line based
A span with column 0 is intended to mean the start of the line, which in utf16 mode must be the 1st character Change-Id: I4b98fe86528b889bbfe4b5ed3ae79c4da81017b1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/167459 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
dbad8e90c9
commit
48d47c461c
|
@ -14,9 +14,12 @@ import (
|
|||
// This is used to convert from the native (always in bytes) column
|
||||
// representation and the utf16 counts used by some editors.
|
||||
func ToUTF16Column(offsets Offsets, p Point, content []byte) int {
|
||||
if content == nil || p.Column < 1 {
|
||||
if content == nil || p.Column < 0 {
|
||||
return -1
|
||||
}
|
||||
if p.Column == 0 {
|
||||
return 1
|
||||
}
|
||||
// make sure we have a valid offset
|
||||
p.updateOffset(offsets)
|
||||
lineOffset := p.Offset - (p.Column - 1)
|
||||
|
|
Loading…
Reference in New Issue