Convert byte offset to char, to fix wrong highlight in non ascii text#95
Open
artur-shaik wants to merge 10 commits into
Open
Convert byte offset to char, to fix wrong highlight in non ascii text#95artur-shaik wants to merge 10 commits into
artur-shaik wants to merge 10 commits into
Conversation
rhysd
requested changes
Nov 30, 2020
| let e.errorlength = len(strcharpart(line_from, e.fromx, e.errorlength)) | ||
| let e.fromx = byteidx(line_from,str2nr(e.fromx))+1 | ||
| let e.tox = byteidx(line_to,str2nr(e.tox)) | ||
| if ch_from =~ '\(\s\|[`<>!@#$%^&*(){}\[\].,:;\"''\\/]\)' |
Owner
There was a problem hiding this comment.
This check looks very ad-hoc.
- What is a purpose of this condition? I could not read the intention
- Please use
=~#since=~behavior depends on user's configuration
Author
There was a problem hiding this comment.
As I said in first message byteidx sometimes return not enough bytes, I couldn't determine why. That's why I used such hacky solution to shift highlight if first character is a symbol or whitespace.
Owner
There was a problem hiding this comment.
I'm still not understanding the problem well. Would you help me to understand it by showing some example which requies this hack?
Author
There was a problem hiding this comment.
Author
|
Ok, I finally could make deep dive in this feature. As a result I could remove this hacky condition. |
Author
|
Also, added |
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 contains code for fixing wrong highlight due to that vim works with bytes not chars. Should fix #61.
Must say that
byteidxmethod in vim sometimes return not exact result, so I used some hacks to shift highlight in right position.I did't test it with multyline highlight, because couldn't emulate such grammatic error.
This feature disabled by default, to enable it you need to set
g:grammarous#convert_char_to_byteto1.