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

x/tools/gopls: incorrect completion ranges for multi-byte character at the end of a document #45883

Open
mattmassicotte opened this issue Apr 30, 2021 · 5 comments

Comments

@mattmassicotte
Copy link

@mattmassicotte mattmassicotte commented Apr 30, 2021

What version of Go are you using (go version)?

go version go1.16.3 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOHOSTARCH="arm64"
GOHOSTOS="darwin"

(however, I'm running gopls built for amd64)

What did you do?

Request completions with gopls at the very end of a document which as a last line of:

Note that there is no newline at the end.

What did you expect to see?

I expected to get completions referencing a location of 2 on this line

What did you see instead?

Got back completions with locations of 3

This looks like a potential latent character encoding issue, but because these kinds of things are really tricky to work out, so it could end up being an issue on my end. However, I am consistently getting back what I believe are invalid character ranges when a multi-byte (but still single UTF16) character is at the very end of the document. Figured it was worth a report.

@cherrymui cherrymui changed the title incorrect completion ranges for multi-byte character at the end of a document x/tools/gopls: incorrect completion ranges for multi-byte character at the end of a document Apr 30, 2021
@gopherbot gopherbot added this to the Unreleased milestone Apr 30, 2021
@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Apr 30, 2021

Loading

@suzmue
Copy link
Contributor

@suzmue suzmue commented Apr 30, 2021

Thanks for filing this issue! This is a somewhat tricky problem. Is this causing you a lot of trouble?

Loading

@mattmassicotte
Copy link
Author

@mattmassicotte mattmassicotte commented Apr 30, 2021

Thank you for responding to it so quickly! It was causing me a little grief, because I was using very strict range validation for my application. I would prefer to keep it that way, especially since this is quite the edge-case. Please don't feel pressure to prioritize this any more highly because of my report.

Can I ask, is this only an issue for the last character, or could this come up in other situations too?

Loading

@hyangah hyangah removed this from the Unreleased milestone May 6, 2021
@hyangah hyangah added this to the Unplanned milestone May 6, 2021
@findleyr
Copy link
Contributor

@findleyr findleyr commented May 6, 2021

This is only an issue for the last character: many of our internal functions don't differentiate between newline-terminated and non-newline-terminated files, so fixing this would require some non-trivial refactoring.

I don't think we can prioritize this now, but we should address it at some point. Thank you for reporting.

Loading

@stamblerre stamblerre removed this from the Unplanned milestone May 6, 2021
@stamblerre stamblerre added this to the gopls/unplanned milestone May 6, 2021
@hyangah
Copy link
Contributor

@hyangah hyangah commented May 6, 2021

@gopherbot remove label Documentation

Loading

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

Successfully merging a pull request may close this issue.

None yet
7 participants