Skip to content
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

Vim normal-mode cursor disappears when moving over multi-codepoint emoji #143

Open
diminutivesloop opened this issue Oct 6, 2023 · 7 comments

Comments

@diminutivesloop
Copy link

Originally reported as an issue w/ Obsidian.

Steps to Reproduce

Using sandbox editor:

  1. Insert a multi-codepoint emoji such as ➡️ Right Arrow Emoji
  2. Place the cursor before the emoji
  3. In vim normal mode move the cursor until it is past the emoji

Expected result

The cursor moves over the emoji just like non-emoji text.

Actual result

After initially highlighting the emoji character, the cursor disappears on its next move (or next several depending on the number of codepoints) and eventually reappears once it is moved to the subsequent character.

Screen.Recording.2023-10-06.at.2.21.37.PM.mov
@RyotaUshio
Copy link

I suspect this is related to the problem that atomic ranges does not work in the normal mode.

https://forum.obsidian.md/t/cm6-are-vim-mode-atomic-ranges-compatible/69667

@RyotaUshio
Copy link

RyotaUshio commented Oct 24, 2023

I think I figured out why it happens. CM6's moveByChar skips atoms (https://github.com/codemirror/view/blob/e6a55a6515521a84e709f02b4eb32e57aebbbfba/src/editorview.ts#L641), while codemirror-vim's moveByCharacters doesn't.

@RyotaUshio
Copy link

RyotaUshio commented Oct 24, 2023

I was able to fix this regarding cursor motions (h/l) by modifying the implementation of moveByCharacters() so that is uses CM6's moveByChar (which respects atomic ranges).

RyotaUshio@e6eb8db

But I'm not sure how I can fix this regarding deletion.

@firai
Copy link

firai commented Nov 10, 2023

Base CM forward deletes atomically, while backspace deletes the characters separately. I wonder if there's code from base CM that could be referenced to atomically delete.

@RyotaUshio, would it make sense to submit the motion patch as a PR ahead of figuring out the deletion part?

@RyotaUshio
Copy link

@firai I might make sense, but to be honest, I currently can't find enough time to fill in the (a little bit strict) PR template.

@RyotaUshio
Copy link

Obsidian has recently released v1.5.3, which includes the fix for this problem.

@diminutivesloop
Copy link
Author

@RyotaUshio I checked the latest version and it resolves the issue except in the case where the emoji is at the end of the line. In that case the cursor still moves twice over the emoji character and disappears when at the very end of the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants