[vim/vim] Scrolling becomes extremely slow after adding a newline and undoing it (#8386)

889 views
Skip to first unread message

reportaman

unread,
Jun 15, 2021, 2:14:08 PM6/15/21
to vim/vim, Subscribed

Describe the bug
Adding a newline and undoing it makes the file scroll extremely slow. I have a video below with nvim, but exact same behavior occurs with vim too! Please excuse me for not creating one more video, I have filed a similar bug on them: neovim/neovim#14818

Steps to reproduce

Preparation:

  1. Save both files scrollslow.vim and problemfile.vim in your computer, let's say in home directory.
  2. Make sure the terminal window is tall enough. In my case the issue is more noticeable on my 27 inch display with terminal size big enough to show 71 lines of vim buffer at a time.

Part-1

    1. Open vim with command ``>>vim -u ~/scrollslow.vim ~/problemfile.vim``.
    2. Press ``G`` to scroll to bottom of file.
    3. Press and hold ``<Up>`` arrow or ``k`` to scroll up.
    4. Close vim: ``:q<CR>``

Note the relatively acceptable speed of scroll, and position of cursor (it will remain in first column).

Part-2

    1. Open vim with command ``>>vim -u ~/scrollslow.vim ~/problemfile.vim``.
    2. Press ``i<CR><Esc>u``.
    3. Press ``G`` to scroll to bottom of file.
    4. Press and hold ``<Up>`` arrow or ``k`` to scroll up.

Note the slow and stuttery scroll and the fact that cursor seems to go all around instead of staying in first column.

Expected behaviour

Editing and undoing the edit should have no effect on the smoothness of scroll...

Attachments

  1. For file problemfile.vim: Download problemfile.txt, and change its extension to .vim to get problemfile.vim.

  2. File slowscroll.vim:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath=&runtimepath

set nocompatible 
filetype plugin on
set noswapfile
set updatetime=50 
set updatecount=0

call plug#begin('~/.vim/plugged')
Plug 'NLKNguyen/papercolor-theme'
call plug#end()

colorscheme PaperColor
set number
set cursorline
set background=dark

Environment

  • vim --version:
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 26 2021 20:32:10)
macOS version - arm64
Included patches: 1-2890
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
  • Operating system/version: macOS BigSur 11.4 ARM64
  • Terminal name/version: WezTerm, Apple's inbuilt Terminal, iTerm2, Alacritty.
  • $TERM: doesn't matter, varies by terminal above. I am using xterm-256color in general.

Video comparing Part-1 and Part-2:

Best viewed in full screen mode with further zoom-in to align video boundary with screen boundary.

https://user-images.githubusercontent.com/71736629/122007240-97b02e80-cd6c-11eb-9f77-b259ed897b2e.mp4


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Jun 23, 2021, 5:18:54 PM6/23/21
to vim/vim, Subscribed

I cannot seem to reproduce. But a couple of questions:

  • do you use any other plugins? Check the scriptnames output.
  • where does the syntax highlighting come from in your case? Try without the syntax highlighting (you might also want to profile the syntax script using :syntime). I can also think, that syntax syncing might cause a slow down. Not sure if messing with :syn sync has an impact.
  • You seem to disable swapfiles by setting updatecount to zero. So why do you then need to set the 'updatetime' setting to such a slow value? Any CursorHold autocommands that could be triggered?

reportaman

unread,
Jun 23, 2021, 5:36:42 PM6/23/21
to vim/vim, Subscribed

@chrisbra I don't, I guess you didn't read the entire file slowscroll.vim above. That's the complete vimrc here given I pass it as argument to -u option. The plugin that gives syntax coloring is also in slowscroll.vim: Plug 'NLKNguyen/papercolor-theme'. I tried by setting set ei=all, it still has same behavior, so there are no auto commands.

It could be that our key repeat rates are different, so you are not able to notice the difference. Here's my analysis of that for someone's pointing out that: neovim/neovim#14818 (comment).

Christian Brabandt

unread,
Jun 24, 2021, 2:06:53 AM6/24/21
to vim/vim, Subscribed

I don't follow. According to your vimrc file, you do not set syntax coloring (Note: the papercolor is just a color theme, it does not (or should not) enable syntax highlighting). So please try without syntax coloring. As said, I could imagine, that since the file is being modified, I syntax engine needs to resync. And since you are using syntax, can you please also post the output of :syntime report?. Also I still do not understand what's the reason for setting updatetime that low. If that hurts your scrolling speed, simply do not set it that low. Especially since you seem to disable swapfiles intentionally (not that I recommend that).

Reply all
Reply to author
Forward
0 new messages