-
Notifications
You must be signed in to change notification settings - Fork 42
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
Convert byte offset to char, to fix wrong highlight in non ascii text #95
base: master
Are you sure you want to change the base?
Conversation
autoload/grammarous.vim
Outdated
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\|[`<>!@#$%^&*(){}\[\].,:;\"''\\/]\)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not understanding the problem well. Would you help me to understand it by showing some example which requies this hack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I finally could make deep dive in this feature. As a result I could remove this hacky condition. |
Also, added |
This PR contains code for fixing wrong highlight due to that vim works with bytes not chars. Should fix #61.
Must say that
byteidx
method 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_byte
to1
.