Pressing up and down arrow keys at the start of a line behaves strangely shortly after entering insert mode
Ilex-verticillata opened this issue · 1 comments
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.
-
In normal mode, put the cursor at the start of the 3rd line.
-
Press
i
. Now the cursor is at the start of the 3rd line in insert mode. -
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. -
In normal mode, put the cursor at the start of the 3rd line.
-
Press
i
. Now the cursor is at the start of the 3rd line in insert mode. -
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.
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