Skip to content

Utf 8 encoding issue #3583

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

Merged
merged 3 commits into from
Jun 4, 2025
Merged

Utf 8 encoding issue #3583

merged 3 commits into from
Jun 4, 2025

Conversation

ChallaHalla
Copy link
Contributor

Motivation

Closes: #3494
Closes: #2446

This PR addresses an issue where UTF-8 encoded text uses incorrect offsets within the language server. The language server was calculating offsets using the number of code points, but UTF-8 code units match the number of bytes (as explained in the spec).

Implementation

To fix this issue, the Scanner class was updated to calculate offset by taking a byte slice of the current text up until a given position, and return the number of chars within the given slice. This number was then added to the offset provided by the new character, which results in a correct char offset.

Automated Tests

Added some unit tests.

Manual Tests

Tested in neo-vim.

ChallaHalla and others added 2 commits June 4, 2025 15:21
@ChallaHalla ChallaHalla requested a review from a team as a code owner June 4, 2025 19:32
@ChallaHalla ChallaHalla added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Jun 4, 2025
Copy link

graphite-app bot commented Jun 4, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Member


How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock force-pushed the utf-8-encoding-issue branch from ff2271a to e4a012f Compare June 4, 2025 20:27
@vinistock vinistock enabled auto-merge (squash) June 4, 2025 20:29
@vinistock vinistock merged commit af30123 into main Jun 4, 2025
36 checks passed
@vinistock vinistock deleted the utf-8-encoding-issue branch June 4, 2025 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

neovim-lsp: Weird behavior after inserting non-ascii characters 100% CPU usage
2 participants