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

Pressing up and down arrow keys at the start of a line behaves strangely shortly after entering insert mode #169

Closed
Ilex-verticillata opened this issue Mar 22, 2024 · 1 comment · Fixed by #170

Comments

@Ilex-verticillata
Copy link

Hi,
I encountered this issue trying to work around #165. Maybe they are related. Maybe they're not. This behaviour exists in the obsidian text editor as well as at https://raw.githack.com/replit/codemirror-vim/master/dev/web-demo.html.

Steps to reproduce

Open a document consisting of one long paragraph with no newlines. Make sure word wrapping is turned on. It should be enough to demonstrate the issue if the paragraph spans 4 wrapped lines.

  1. In normal mode, put the cursor at the start of the 3rd line.

  2. Press i. Now the cursor is at the start of the 3rd line in insert mode.

  3. Press the up arrow key.
    The expected behaviour is that the cursor jumps to the start of line 2. But it actually jumps to the character in line 1 immediately above the last character of line 2. If line 2 is longer than line 1, it jumps to the last character of line 1.

  4. In normal mode, put the cursor at the start of the 3rd line.

  5. Press i. Now the cursor is at the start of the 3rd line in insert mode.

  6. Press the down arrow key.
    The expected behaviour is that the cursor jumps to the start of the 4nd line. But it actually jumps to the character in line 3 immediately below the last character of line 2. If line 2 is longer than line 3, it jumps to the last character of line 3.

Additional information

It doesn't seem like it matters how the cursor gets to the start of the 3rd line, as long as it happens in normal mode. It also behaves like this if you put the cursor at the end of line 2 and press a such that you enter insert mode with the cursor at the start of line 3.

@nightwing
Copy link
Collaborator

Seems to be a bug in codemirror, when EditorSelection.range creates a cursor that is displayed as a range with assoc=1, but behaves as one with assoc=-1

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

Successfully merging a pull request may close this issue.

2 participants