Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode characters are not handled properly #52

Closed
runningwild opened this issue Sep 3, 2011 · 2 comments
Closed

Unicode characters are not handled properly #52

runningwild opened this issue Sep 3, 2011 · 2 comments

Comments

@runningwild
Copy link

I am using gocode via GoSublime, but I've tested this out by running gocode manually as well.

Consider the following program:

package main

import (
  "os"
)

// U+03C0: π
func main() {
  os.
}

If I ask gocode for autocomplete suggestions at position 65 (right after 'os.') it returns
[2, [{"class": "package", "name": "os", "type": ""}]]

If I ask gocode for autocomplete suggestions at position 66 (the next line, right before the '}') it returns everything from the os package. If the 'π' is replaced by any ASCII character the autocomplete returns all of this at position 65 as expected.

@nsf
Copy link
Owner

nsf commented Sep 3, 2011

Gocode handles unicode correctly, believe me, I designed it that way. Probably GoSublime or whatever it is, misunderstands gocode's input expectations. It expects as a cursor position offset in bytes. And the file encoding must be utf-8 (as Go compiler expects for any Go source file). Therefore byte offset for multibyte characters != character offset. Works fine in vim:
screenshot

@nsf
Copy link
Owner

nsf commented Sep 4, 2011

So, the patch is here. Now gocode understands cursor position specified as a characters offset (need to prefix the number with 'c' or 'C'). I guess the issue will be resolved on the gosublime side as well (if not already). Closing it.. reopen if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants