Scrolling in vim mode using HJKL keys unintentionally opens folds

Steps to reproduce

(with vim mode enabled)

  1. make a file with the following text:
# abcdef
## abcdefg
text text text text text text
text text text text text text
text text text text text text.
  1. fold the H2 heading (abcdefg)
  2. place cursor on g in H2 heading
  3. go up one line (press K)
  4. go down one line (press J)

Expected result

The cursor should return to the char g or atleast return somewhere on the heading

Actual result

The fold is opened and the cursor jumps to the end of the last line. In the above example it jumps to the fullstop

Environment

  • Operating system: Ubuntu 20.04
  • Obsidian version: 8.0.0

Additional information

This is a minor issue, but in vim mode it is common to scroll in a file using the J and K keys (like using arrow keys in non-vim mode) and random folds opening as you scroll and jumping of the cursor interrupts the flow of editing a lot, especially if the fold has lots of text.

I suspect it might be due to the editor wanting to place the cursor at the end of the line as you scroll, but instead placing it at the end of the fold. In vim when going down from a longer line to a shorter line it jumps to the end of the line depending on where the cursor was initially, that might be whats affecting this.

This happens in a lot of random places in my files, the above example was just one i was able to reproduce. I also was not able to reproduce this in normal (non vim) mode.

2 Likes

A post was merged into an existing topic: VIM Mode - Quality of Life Improvements