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
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@mattmassicotte
Copy link

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 Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Apr 30, 2021
@gopherbot gopherbot added this to the Unreleased milestone Apr 30, 2021
@cherrymui
Copy link
Member

cc @stamblerre @suzmue

@suzmue
Copy link
Contributor

suzmue commented Apr 30, 2021

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

@mattmassicotte
Copy link
Author

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?

@hyangah hyangah modified the milestones: Unreleased, Unplanned May 6, 2021
@findleyr
Copy link
Contributor

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.

@stamblerre stamblerre modified the milestones: Unplanned, gopls/unplanned May 6, 2021
@hyangah
Copy link
Contributor

hyangah commented May 6, 2021

@gopherbot remove label Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

7 participants