SublimeLinter-gotype icon indicating copy to clipboard operation
SublimeLinter-gotype copied to clipboard

Markers are shifted right after non-ASCII characters: gotype columns are UTF-8 bytes, linter needs column_unit = 'utf8'

Open dpc00 opened this issue 2 months ago • 0 comments

The markers are shifted to the right by the number of extra bytes of every non-ASCII character earlier on the line, because gotype reports columns in UTF-8 bytes and the linter treats them as character columns.

Reproduce (Windows 11, Sublime Text 4215, SublimeLinter 4.30, SublimeLinter-gotype current, gotype built with go install golang.org/x/tools/cmd/gotype@latest (x/tools v0.50.0), Go 1.26.5; go.mod with module example.com/gotype_test, main.go):

package main

func main() {
	var a int = "plain"
	s := "ééé"; var b int = undefinedB
	t := "😀"; var c int = undefinedC
	_, _, _, _, _ = a, b, c, s, t
}

gotype -t -e . reports:

main.go:4:14: cannot use "plain" (untyped string constant) as int value in variable declaration
main.go:5:29: undefined: undefinedB
main.go:6:27: undefined: undefinedC

undefinedB is the 26th character of line 5 but byte column 29 (three é, one extra byte each); undefinedC is the 24th character of line 6 but byte column 27 (the emoji is 4 bytes).

Actual (the text SublimeLinter highlights):

line should be is
4 (ASCII before it) the start of "plain" the start of "plain"
5 (after ééé) undefinedB efinedB
6 (after the emoji) undefinedC efinedC

Fix: add column_unit = 'utf8' to the Gotype class (core 4.30 has this attribute). I set it on the running class and relinted the same file: the markers are then exactly undefinedB and undefinedC and line 4 is unchanged.

(The same problem exists in SublimeLinter-govet: SublimeLinter/SublimeLinter-govet#17.)

dpc00 avatar Oct 01 '26 23:10 dpc00