Vim mode: weird behaviour with cursor at the start of lines

Steps to reproduce

In a sandbox vault, turn on vim mode and type one long paragraph with no newlines. Make sure word wrapping occurs. It should be enough to demonstrate the issue if the paragraph spans 4 wrapped lines. For a narrow enough window, the following paragraph works:

Aaaaaaaaaa Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb Ccccccccccccccccccccccc Ddddddddddddddddddddddddddddddd

Make sure that the window is too narrow to accomodate more than one word per line, but wide enough to prevent individual words from being broken over two 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. The actual behaviour is that the cursor 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 4th line. The actual behaviour is that the cursor 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.

(Also, similar weird behaviour exists with the gk command with the cursor at the start of a wrapped line.)

Did you follow the troubleshooting guide?

Yes

Expected result

At step 3, the cursor should jump to the start of line 2.
At step 6, the cursor should jump to the start of the 4th line,

Actual result

At step 3, the cursor 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.
At step 6, the cursor 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.

Environment

SYSTEM INFO:
Obsidian version: v1.6.7
Installer version: v1.5.11
Operating system: Windows 10 Pro 10.0.22631
Login status: not logged in
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


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.

This seems like a bug from an older version of codemirror, since fixed; see fix broken arrow navigation on wrapped lines by nightwing · Pull Request #170 · replit/codemirror-vim · GitHub and the issues mentioned therein.

I am also able to reproduce this issue. I wasn’t able to test on the CodeMirror testing website since it doesn’t let you wrap like Obsidian does :sweat_smile:

SYSTEM INFO:
Obsidian version: v1.6.7
Installer version: v1.6.7
Operating system: Windows 10 Home 10.0.19045
Login status: not logged in
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 0
Plugins enabled: 0

RECOMMENDATIONS:
none

Seems like it’s been fixed in 1.7, thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.