psliwka / vim-smoothie

Smooth scrolling for Vim done rightšŸ„¤
MIT License
988 stars 27 forks source link

Folding causes the cursor stuck #40

Open JS-Zheng opened 2 years ago

JS-Zheng commented 2 years ago

vim-smoothie version: b440f13 vim version: 8.2.4700

As mentioned in the title, when I use the scrolling commands (e.g., <C-D>, zt) to cross the continuous folding, the cursor will be stuck. Then, j and k cannot work normally, for example:

"""""""""""""""""""""""""
" +-- A (Fold)
"""""""""""""""""""""""""
"""""""""""""""""""""""""
" B {{{ (Fold)
"""""""""""""""""""""""""
[CURSOR] (`j/k` cannot work after `zt`)

" }}}
"""""""""""""""""""""""""
" C {{{ (Fold)
"""""""""""""""""""""""""
" }}}
"""""""""""""""""""""""""
Freed-Wu commented 2 years ago

I also met this similar bug, In a folded text contain about 1000 lines, press gg then G, then k cannot move, after waiting a few seconds or press za, it can recover to normal.

AnkushMalaker commented 2 years ago

I can verify the same bug. I'd really like to continue using this plugin but this bug is a very common occurrence in my workflow. Could I contribute to fixing this somehow? I'm new to vim/vimL and would require some direction, though.

Freed-Wu commented 2 years ago

I believe this bug occur after https://github.com/psliwka/vim-smoothie/issues/34. A older vim-smoothie can avoid this bug.

psliwka commented 2 years ago

Thanks for reporting! Unfortunately I couldn't figure out yet why does that happen. For now I added a workaround, which should cause the plugin to jump directly to the target position if it detects that animation is stuck. It's not pretty, but at least will prevent trapping users and their cursors ;)

JS-Zheng commented 2 years ago

Hi @psliwka, Thanks for workaround. IMHO, the problem may be because vim-smoothie does not consider the folded lines. Perhaps It can use foldclosedend() to calculate end line of folds.

AnkushMalaker commented 2 years ago

@psliwka Thanks, you're the MVP. It doesn't get stuck after the update. If it helps diagnose at all, I use fzf with nvim and whenever I got this cursor stuck issue, I couldn't open fzf. I get an error with something along the lines of "Can't exit terminal mode and go into normal mode". Best of luck and thanks again!