Fix the diagnostic and correction for non-ascii text#3
Open
benjamin-voisin wants to merge 1 commit into
Open
Conversation
In lines where some characters were non-ascii, the languagtool offset, the byte offset, and the column offset were computed differently, creating badly formatted responses. This fix uses the builtin vim function to compute the actual number of character in a string, instead of using the number of bytes, and provides the correct offset for the diagnostic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #2 by using the vim strcharlen instead of the lua length function, providing the actual number of character and not the number of bytes, as the languagetool offset speaks with characters offset.
And then it uses the vim function byteidx to get the byte offset remaining from the number of character, to tell neovim to highlight and fix the proper part of the text.