Folded sections/lists are expanded when cursor passes them in vim mode

When in vim-mode, moving the cursor to or from a line with folded content (either sub-points in a bullet lists or a folded section) will often expand it, with the cursor landing in the expanded section.

Steps to reproduce

Enable vim mode.
Create a nested list, and fold the top-level bullets points.
Use j/k or up/down arrow keys to navigate between the top-level bullet points in normal mode.
(Failure happens more often if the top-level bullet points are long enough to wrap.)

Expected result

The cursor moves between the top-level bullet points.

Actual result

Often (but not always) the bullet point that the cursor moves to or from will expand (unfold), and the cursor will move to the first or last of the expanded items.

Environment

  • Operating system: macOS 11.2.1
  • Obsidian version: v.0.11.3
8 Likes

When I move cursor in Vim mode from a fold line with key j / k, it unfold automatically sometimes according cursor position or just to expand with no condition, but it doesn’t apperence in the edit mode. So I have to move the cursor with mouse or in edit mode to prevent it unfold.

I have reported to the plugin Outliner’s author, and as he said it is like an Obsidian’s vim mode problem.

Please take a look on it, appreciate for all your efforts!

  • System: MacOS 11.2.3
  • Obsidian Version: 11.13 the latest version right now.
4 Likes

I have the same problem. I found minimal steps to reproduce:

  1. Write this in obsidian:
- aax
- a
	- a
  1. Fold the second bullet
  2. Place cursor at x
  3. Press j
  4. (optional) sometimes you have to move up and down once more (kj)

obsidian v0.12.19

So they get unfolded if the cursor is at a character far to the right, and we move to a short line (cursor position > new line length). Does anyone have any idea why that may happen?

This issue makes folding in vim mode almost unusable :frowning:

1 Like

It looks that they may be two separate issues.
I also experienced the one @lukas describes, but I fixed it by remapping:

nmap j gj
nmap k gk

with the vimrc pluggin.

2 Likes

This worked for going down in vim, but not going up. Thanks anyways!

1 Like

This bug is still around and it is what keeps me from switching to obsidian. It makes vim mode unusable with collapsible lists, for me. Would really appreciate a fix.

Same for me. I’d go all in on Obsidian if not for this.

I can’t reproduce this bug anymore. Can somebody provide repro steps in the latest stable version of obsidian in the sandbox vault? Thanks

If the cursor is at the beginning of the line, it won’t unfold, but if the cursor is at the end of the line while navigating (especially when it falls on the 3-dots “…”), it will automatically unfold. It would be nice if it would only unfold when either using a shortcut or clicking the unfold button using mouse. Right now, you can accidentally unfold it while navigating if you’re not super careful where your cursor is.

This is not a VIM specific issue. It happens also without VIM.

In which circumstances it happens when the cursor is NOT at or after the ...?
Can you provide reproducible steps?

if you toggle fold at title and vim j to move down, Folded section are expanded

# title:fold here
![[path-to-file]]

Hey, here are the steps to reproduce the bug in vim-mode - it depends on the length of the parent section you want to fold.

- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo suscipit risu
	- [ ] Lorem ipsum dolor sit amet,
	- [ ] Lorem ipsum dolor sit amet,
	- [ ] Lorem ipsum dolor sit amet, 
- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo suscipit risus a mollis.
	- [ ] Lorem ipsum dolor sit amet, 
	- [ ] Lorem ipsum dolor sit amet, 
	- [ ] Lorem ipsum dolor sit amet, 
- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo suscipit risus a mollis. Class aptent taciti sociosqu ad litora 
	- [ ] Lorem ipsum dolor sit amet, 
	- [ ] Lorem ipsum dolor sit amet, 
	- [ ] Lorem ipsum dolor sit amet, 

In this example are three foldable parent sections.
The first one fits in one line, the second one fits in two lines if you got the cursor on the checkbox at the beginning, the third one only fits in two lines.
NOTE: To reproduce this situation, you need to switch on the “Readable line length” option.

If you fold every three sections and place the cursor on the very top, you move the cursor with the j button and the sections that did not fit in one line are going to be unfolded. Same situation if you start from the bottom and go up with the cursor using the vim-mode button k.

So the first section is not unfolded as it fits in one line. The second section is only unfolded if the cursor is at the very beginning (because then is does not fit in one line). The third section is unfolded every time because it does not fit in one line.

I could not reproduce this bug without vim-mode.

1 Like

This reproduction works for me. (Except that when I start from the bottom, only the 2nd section unfolds. Not the 3rd section.)

There will be some fixes for the issues reported in this thread in 1.5.4.
If you still have problems please open a new bug report and be specific about your problem with repro steps. Also make sure if it’s something that happens only when vim is enabled.

2 Likes

For those still having issues with vim nav, see here: