Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Auto-completion stops working when unicode chars are present #1431

Closed
ramya-rao-a opened this issue Dec 31, 2017 · 11 comments
Closed

Auto-completion stops working when unicode chars are present #1431

ramya-rao-a opened this issue Dec 31, 2017 · 11 comments
Labels

Comments

@ramya-rao-a
Copy link
Contributor

Copying @dc0d's comments from #441 (comment)

I've managed to reproduce it reliably.

When adding this comment with unicodes:

// 𐏃𐏂𐏁𐏀𐎿𐎾𐎽𐎼𐎻𐎺𐎹𐎸𐎷𐎶𐎵𐎴𐎳𐎲𐎱𐎰𐎯𐎮𐎭𐎬𐎫𐎪𐎩𐎨𐎧𐎦𐎥𐎤𐎣𐎢𐎡𐎠 := 1

It stops working and when this comment gets removed, it starts working.

@ramya-rao-a
Copy link
Contributor Author

@dc0d For some reason when I copy your example of unicode chars I get the below and I cannot repro

screen shot 2017-12-30 at 11 19 01 pm

So I tried a few chinese chars instead and I still cannot repro.

Can you try running gocode from the command line and see if you get any errors?
You can use the show offset extension to get the offset you need to run gocode

@dc0d
Copy link

dc0d commented Dec 31, 2017

Thanks for the followup!

Those are Old Persian characters, existing in Ubuntu 16.04. I've put the main.go and the output from gocode here.

@ramya-rao-a
Copy link
Contributor Author

ramya-rao-a commented Dec 31, 2017

Used your main.go.. Still can't repro the issue.

The output you have shared seemed to be from the gocode -debug -s i.e. the daemon/server that's running to serve the requests

Instead can you share the output from the client? Example: gocode -f=json autocomplete path-to-your-file c266 where 266 is a random number I used, but you should use the char offset (for which you can use the show offset extension

@dc0d
Copy link

dc0d commented Dec 31, 2017

I don't get any outputs from the command line. Maybe I'm doing it wrong. I've installed the extension and edited the file with a normal text editor (gedit) so gofmt won't run. But no output appeared inside the terminal.

@ramya-rao-a
Copy link
Contributor Author

gocode uses a client/server architecture.
Running gocode -s or gocode -debug -s, runs gocode in server mode
What you have shared before is the output from gocode -debug -s
The Go extension for VS Code runs gocode in client mode, which you can also do from the command line. This is what I need you to share.

  • Edit your file in your normal text editor. Type a letter for which you would expect auto-completions. Make note of the character offset under the cursor. Save the file.
  • Kill all processes of gocode
  • Run gocode -in file-path autocomplete c123 where 123 is the character offset. Below is an example of how I ran gocode in the command line

screen shot 2017-12-31 at 11 56 57 am

@dc0d
Copy link

dc0d commented Dec 31, 2017

Still getting nothing. But an interesting observation. When typing log. before the unicode comment, proper auto-completion will be shown:

before

But if log. is type after that line, it shows the wrong list of suggestions (just Go's built-in types and functions; keywords):

after

@ramya-rao-a
Copy link
Contributor Author

ramya-rao-a commented Dec 31, 2017

Still getting nothing

Are you getting nothing even without the unicode comment? Ensure to pass the file path in the -in flag

wrong list of suggestions (just Go's built-in types and functions; keywords

Those are still coming from gocode itself

@dc0d
Copy link

dc0d commented Dec 31, 2017

With this new command, it worked.

These are related to the pictures previously posted. For the line before unicode comment:

$ gocode -in /path/to/main.go autocomplete c52
Found 24 candidates:
  const LUTC 
  const Ldate 
  const Llongfile 
  const Lmicroseconds 
  const Lshortfile 
  const LstdFlags 
  const Ltime 
  func Fatal(v ...interface{})
  func Fatalf(format string, v ...interface{})
  func Fatalln(v ...interface{})
  func Flags() int
  func New(out io.Writer, prefix string, flag int) *log.Logger
  func Output(calldepth int, s string) error
  func Panic(v ...interface{})
  func Panicf(format string, v ...interface{})
  func Panicln(v ...interface{})
  func Prefix() string
  func Print(v ...interface{})
  func Printf(format string, v ...interface{})
  func Println(v ...interface{})
  func SetFlags(flag int)
  func SetOutput(w io.Writer)
  func SetPrefix(prefix string)
  type Logger struct

For the line after the unicode comment:

$ gocode -in /path/to/main.go autocomplete c134
Found 42 candidates:
  const false 
  const iota 
  const nil 
  const true 
  func append([]type, ...type) []type
  func cap(container) int
  func close(channel)
  func complex(real, imag) complex
  func copy(dst, src)
  func delete(map[typeA]typeB, typeA)
  func imag(complex)
  func len(container) int
  func main()
  func make(type, len[, cap]) type
  func new(type) *type
  func onSignal(f func(), sig ...os.Signal)
  func panic(interface{})
  func print(...interface{})
  func println(...interface{})
  func real(complex)
  func recover() interface{}
  package log 
  type bool built-in
  type byte built-in
  type complex128 built-in
  type complex64 built-in
  type error interface
  type float32 built-in
  type float64 built-in
  type int built-in
  type int16 built-in
  type int32 built-in
  type int64 built-in
  type int8 built-in
  type rune built-in
  type string built-in
  type uint built-in
  type uint16 built-in
  type uint32 built-in
  type uint64 built-in
  type uint8 built-in
  type uintptr built-in

@ramya-rao-a
Copy link
Contributor Author

Thanks @dc0d
That confirms that the issue is upstream with gocode.

I have logged nsf/gocode#489 to track this issue upstream

@ramya-rao-a
Copy link
Contributor Author

@dc0d Pushed a fix to use byte offset instead of char offset when calling gocode. Can you confirm that this fixes the current issue? All you have to do is

@ramya-rao-a
Copy link
Contributor Author

ramya-rao-a commented Jan 4, 2018

This fix is now out in the latest update to the Go extension (0.6.71)

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants