nsf/gocode

gocode gives incorrect completions in a position after unicode characters

ramya-rao-a opened this issue · 3 comments

From microsoft/vscode-go#1431 by @dc0d

Sample code where the issue repros is here

gocode gives correct completions when triggered above the line with unicode chars in the above example, but not in the line after it

Screenshots for this issue from vscode is here

Output of the gocode cmd for this issue is here

@ramya-rao-a Are you sure the offsets are correct?

After adding \tlog. to your code ...fmt.Println(len(s), utf8.RuneCount(s)) tells me the offsets are 266 and c158. This is also confirmed by printing what GoSublime uses and I can't reproduce the issue in either GoSublime or using gocode directly.

If VS Code gives you the offsets in bytes (unlike Sublime Text), when you pass c123 to gocode, the completion will be wrong. So in that case you'd need to pass 123 instead of c123.

nsf commented

I should correct gocode docs though. Gocode uses either unicode code points as offset or bytes. Never unicode characters. There is a similar issue: #460. I don't think I'll do anything about this on my end, except making docs more clear. Other editors use "c" prefix and send unicode code points already. Plus calculating proper unicode characters offset is complicated (maybe).

If VS Code gives you the offsets in bytes (unlike Sublime Text), when you pass c123 to gocode, the completion will be wrong. So in that case you'd need to pass 123 instead of c123.

@DisposaBoy VS Code is not passing the byte offset but is using the c prefix. I guess we will have to change to pass the offset in bytes and remove the c prefix

Will close this issue and try the above fix in VS Code.

Thanks!