Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Invalid position in Completions #257

Open
mjshashank opened this issue Apr 11, 2018 · 6 comments
Open

Invalid position in Completions #257

mjshashank opened this issue Apr 11, 2018 · 6 comments

Comments

@mjshashank
Copy link

I'm working on a custom client with this language server.

When I requests for a completion with the files contents as:
im and line as 0 and character as 2, I get error: go completion error: Error: invalid position: (character 2 is beyond first line boundary)

But when I make a request with a blank line or space appended as:
im\n or im and the same line, character values of 0,2 I receive accurate completions.

Is this a known issue or expected behaviour? Else, what am I doing wrong here?

@lloiser
Copy link
Contributor

lloiser commented Apr 11, 2018

This is fixed in #83 with commit 8b3e27e#diff-78179d406a671306d86895d9604fca17

@pwaller
Copy link

pwaller commented Jun 13, 2018

I'm seeing this in both vscode and atom in very different environments. (Home Ubuntu Desktop atom, Work OSX vscode). Tested on commit e526744 (Tue May 29 2018).

Here is a characteristic error message, which I've seen in both the vscode console and in atom, if I try to use something like go to def:

[Error - 10:02:02] Request textDocument/definition failed.
  Message: invalid position: /path/to/blah.go:15:17 (character 17 is beyond first line boundary)
  Code: 0 

And here's another one, an error message like this is emitted for every keypress:

jsonrpc2 handler: notification "textDocument/didChange" handling error: received textDocument/didChange for invalid position {'\x13' ' '} on "blah.go": character 32 is beyond first line boundary

I have verified that the offset is valid in the text editor. Could it be that go-langserver somehow is not using the content as it appears in the editor? Saving the file does not seem to help, but closing the file and reopening it appears to help at least sometimes. I don't rely on the code formatter to format my code, so usually saving doesn't result in the file changing.

It's not easy to reproduce. It just starts happening at some point, and manifests as completion ceasing and go-to-def not working. If I exit and go back into the editor, it works for a little while. I can't point to a public repository where this manifests, I've only noticed it on two completely different companies' fairly large closed source projects. I don't hit it fast enough editing code separately from these repos to be able to give an independent reproducer.

/xref microsoft/vscode-go#1628 where there are other vscode users reporting this issue recently.
/cc @slimsag hi :) 👋

@butterflyfish
Copy link

i'm looking forward to address this problem also. thank you!

@butterflyfish
Copy link

this issue still exists on neovim with plugin ncm2 and LanguageClient-neovim

@fntlnz
Copy link

fntlnz commented Aug 21, 2018

I had the exact same problem if I start go-langserver without arguments but I was able to have it working with the following arguments:

go-langserver -gocodecompletion -freeosmemory=false

@mikefaille
Copy link

mikefaille commented Dec 2, 2018

I get this problem too using Emacs 27-trunk + eglot. To fix it, I delete eglot and jsonrpc from emacs using package-delete function. I update go-languageserver and I reinstall eglot. Then everything work without special tweaks.

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

No branches or pull requests

6 participants