Skip to content

Neovim seems to interpret positions incorrectly #127

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

Closed
Alloyed opened this issue Sep 6, 2017 · 4 comments
Closed

Neovim seems to interpret positions incorrectly #127

Alloyed opened this issue Sep 6, 2017 · 4 comments

Comments

@Alloyed
Copy link

Alloyed commented Sep 6, 2017

the LSP spec specifies that positions are (line, character) pairs, where the character describes the offset from the start of the line in UTF-16 code units.

neovim seems to be interpreting them as visual columns instead.
Here are some test cases:

local a
------^
	local b
-------^
b = "😬" local c = nil
-----------------^

a() b() c()

here are the values from my language server (line:character):

a = 0:6
b = 2:7
c = 4:17 (edit: should be 4:15)

test case A is a control.
test case B has a tab character, which is one character that represents 8 columns
test case C has an emoji, which should be counted as two utf 16 code units

EDIT: C seems to be a goof on my part (I sent bytes instead of code units), I'll leave it as an example but neovim has the correct behavior here

@autozimu
Copy link
Owner

autozimu commented Sep 6, 2017

I don't get it. Could you please elaborate a bit more? What language server, what test file, what's the expect result, what's the real result you got, etc.

@Alloyed
Copy link
Author

Alloyed commented Sep 6, 2017

the language server is one I'm making right now for the lua language. I don't have a release I can share, but I can include:

@autozimu
Copy link
Owner

autozimu commented Sep 7, 2017

I've tried similar situation with rls as language server, and it doesn't have the described issue. Also, I've verified neovim jumping cursor function, cursor(), can correctly handle tab characters.

Not sure what's the real cause on your side. But I cannot do much without stable reproduction steps.

@autozimu autozimu closed this as completed Sep 7, 2017
@Avi-D-coder
Copy link

Avi-D-coder commented Mar 27, 2019

@autozimu If cursor is still used then UTF-8 codeunits/bytes are used to index.
Could/would you ever conform to the protocol 3.0 and use UTF-16 units?

I am conducting a survey to inform the debate over what unit ranges should use in the Language Server Protocol.
The debate is occuring in issue #376.

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

3 participants