-
Notifications
You must be signed in to change notification settings - Fork 279
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
Handle composed characters in evil-range #1664
base: master
Are you sure you want to change the base?
Conversation
A composed character is a way of visually replacing a string of characters with a single glyph. If beg in the call to evil-range lies in this hidden sequence, adjust the position to the beginning of the sequence. Similarly, make sure end comes at the end of any such hidden sequence. The purpose is to prevent evil from unintentionally modifying part of a hidden sequence of characters.
Account for beg > end case and case where beg or end are nil
Looks fine to me, although I don't know much about composition. The tests look good, but maybe something using |
Sure, I can add more tests. FWIW, here's the basic idea. If you have a buffer with text like
you can use
anywhere in the buffer. However, the change is only cosmetic and prior to this evil only "saw" and acted on the string
because after hitting After this PR, By the way, it is a little presumptuous to assume that the user wanted |
Thanks for that great explanation. When I'm in emacs-state (or for that matter, insert-state, which doesn't map delete differently) and press delete before |
Well... it's complicated. I brought up We could try to stay more faithful to the emacs behavior and only make the required changes for regions, but I'm not sure if that is the right answer here. I found this plugin for vim, but it opens up all of the composed characters on the line, so I can't check the behavior there. I personally like the behavior in this PR, because it lets me pretend that all of these latex macros are just single unicode characters, but hiding the behavior behind a flag would be fine with me. One issue with the flag is that it's going to be hard to make it obvious what it means to an average user. |
Cool - all understood. I think flags which are hard to understand to the average user are fine as long as they are off by default and have a good doc-string. |
Thanks for checking. I'm happy to tweak or improve as necessary. I also think hiding it behind a flag makes sense for now. I did try to reproduce what you were talking about, but had some difficulty.
What seems to be happening is that after the paste on a new line the cursor is in the last position of the line. evil then adjusts the cursor back one position, which is inside the composed lambda, and emacs never readjusts it outside of the lambda.
No problem. I'm also going to put it behind a flag that makes it and experimental feature. |
Allows user to disable special handling of composed characters. See the docstring for more information.
This is a low-level fix for the composed characters problem (see #1656). The idea is to prevent
evil-range
from returning a range that lands inside a sequence of composed characters. I think this makes sense, becauseevil-range
already takes care to return a valid range through callingevil-normalize-position
, and having the range(beg end)
start or end inside a sequence of hidden characters, seems like it should be considered invalid.If this seems too aggressive, I could see hiding this feature behind a flag.
Also added some tests.