[vim/vim] Total screen redraw on relative number change (#4697)

Skip to first unread message

Max Sagebaum

unread,
Jul 19, 2019, 6:33:04 AM7/19/19
to vim/vim, Subscribed

I use the relative numbering feature of vim only in the active buffer. Every time I switch the buffer relative numbering is enabled in the new buffer and disabled in the old one. The same is true if editing starts. Then relative numbering is switched off. After editing is finished relative numbering is turned on.

Describe the bug
Using :set relativenumber and :set norealtivenumber lets the whole screen flash.

To Reproduce

  1. Run vim --clean <file>
  2. Type ':set number'
  3. Type ':set relativenumber'
    screen flashes
  4. Type ':set norelativenumber'
    screen flashes

Expected behavior
Just the numbering is changed in steps 3 and 4. The text should not be redrawn.

Environment:

  • Vim version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 28 2019 09:33:25)
Included patches: 1-1602
Modified by <bugz...@redhat.com>
Compiled by <bugz...@redhat.com>
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_any_white
+arabic            +file_in_path      +mouse_urxvt       -tcl
+autocmd           +find_in_path      +mouse_xterm       +termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
-balloon_eval      -footer            -mzscheme          +termresponse
+balloon_eval_term +fork()            +netbeans_intg     +textobjects
-browse            +gettext           +num64             +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     +perl/dyn          -toolbar
+cindent           +job               +persistent_undo   +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           +python/dyn        +visual
+cmdline_info      +libcall           +python3/dyn       +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          +ruby/dyn          +wildmenu
+cursorbind        +lua/dyn           +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con        +mksession         +smartindent       -X11
+diff              +modify_fname      -sound             -xfontset
+digraphs          +mouse             +spell             -xim
-dnd               -mouseshape        +startuptime       -xpm
-ebcdic            +mouse_dec         +statusline        -xsmp
+emacs_tags        +mouse_gpm         -sun_workshop      -xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary        
+extra_search      +mouse_sgr         -tag_old_static    
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim81"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld  -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux   -lncurses -lacl -lattr -lgpm -ldl   -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib  -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -lutil -lc
  • OS: Linux Fedora 5.1.15-300.fc30.x86_64 x86_64
  • Terminal: GNOME Terminal

Additional context
I have been using this configuration for about a year but the flashing only started recently. I think it started with the update from Fedora 29 to 30. But it seems they use the same vim version.


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

StarryLeo

unread,
Jul 26, 2019, 4:19:33 AM7/26/19
to vim/vim, Subscribed

The same issue as above, because I use the following autocmds to toggle the relativenumber option:

set number relativenumber
autocmd InsertEnter * setlocal norelativenumber
autocmd InsertLeave * setlocal relativenumber

This looks like the version of the last two months has this problem.

Yegappan Lakshmanan

unread,
Jul 26, 2019, 10:12:01 AM7/26/19
to vim_dev, reply+ACY5DGFWGC2PO7SCGC...@reply.github.com, vim/vim, Subscribed
Hi,

On Fri, Jul 26, 2019 at 1:19 AM StarryLeo <vim-dev...@256bit.org> wrote:
>
> The same issue as above, because I use the following autocmds to toggle the relativenumber option:
>
> set number relativenumber
> autocmd InsertEnter * setlocal norelativenumber
> autocmd InsertLeave * setlocal relativenumber
>
> This looks like the version of the last two months has this problem.
>

To address screen redraw problems when 'signcolumn' is set, when the 'number'
or 'relativenumber' options are set or cleared, the screen is
completely refreshed.
This logic was introduced in patch 8.1.1587. This logic needs to be optimized to
take into account the case where the number column is already displayed but
only the 'relativenumber' option is toggled.

- Yegappan

vim-dev ML

unread,
Jul 26, 2019, 10:12:27 AM7/26/19
to vim/vim, vim-dev ML, Your activity

Bram Moolenaar

unread,
Jul 27, 2019, 9:14:17 AM7/27/19
to vim...@googlegroups.com, Yegappan Lakshmanan, reply+ACY5DGFWGC2PO7SCGC...@reply.github.com
We already draw only then number column when the cursor moves and
'relativenumber' is set. We could do the same when the value of
'relativenumber' changes, instead of redrawing everything.
Would require a new redraw type, perhaps VALID_RENUMBER.
It would be set when the option value changes, and used in win_update():

if (wp->w_p_rnu || type == VALID_RENUMBER)

Not 100% sure this works though.

--
Westheimer's Discovery:
A couple of months in the laboratory can
frequently save a couple of hours in the library.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

vim-dev ML

unread,
Jul 27, 2019, 9:14:40 AM7/27/19
to vim/vim, vim-dev ML, Your activity

Yegappan Lakshmanan

unread,
Jul 27, 2019, 2:08:32 PM7/27/19
to vim_dev, reply+ACY5DGFWGC2PO7SCGC...@reply.github.com, vim/vim, Subscribed
Hi,

On Fri, Jul 26, 2019 at 1:19 AM StarryLeo <vim-dev...@256bit.org> wrote:
>
> The same issue as above, because I use the following autocmds to toggle the relativenumber option:
>
> set number relativenumber
> autocmd InsertEnter * setlocal norelativenumber
> autocmd InsertLeave * setlocal relativenumber
>
> This looks like the version of the last two months has this problem.
>

Can you try the attached patch and see whether the screen refresh issue
on toggling the 'number' or 'relativenumber' option is fixed?

Thanks,
Yegappan
sign_refresh.diff

vim-dev ML

unread,
Jul 27, 2019, 2:08:54 PM7/27/19
to vim/vim, vim-dev ML, Your activity

Max Sagebaum

unread,
Jul 27, 2019, 2:21:24 PM7/27/19
to vim/vim, vim-dev ML, Comment

I can try, but there was no patch attached.


You are receiving this because you commented.

K.Takata

unread,
Jul 27, 2019, 2:31:29 PM7/27/19
to vim/vim, vim-dev ML, Comment

See this: https://groups.google.com/d/msg/vim_dev/00yUHYHlP-c/Gf-ZVci9BgAJ


You are receiving this because you commented.

Yegappan Lakshmanan

unread,
Jul 27, 2019, 2:33:16 PM7/27/19
to vim_dev, reply+ACY5DGDVDQBBKG2IHT...@reply.github.com, vim/vim, vim-dev ML, Comment
Hi,

On Sat, Jul 27, 2019 at 11:21 AM Max Sagebaum <vim-dev...@256bit.org> wrote:
>
> I can try, but there was no patch attached.
>

I am attaching a slightly updated patch. I think the patch shows up only in
the mailing list. Can you try downloading the patch from the vim-dev mailing
list archive?

- Yegappan
sign_refresh.diff

vim-dev ML

unread,
Jul 27, 2019, 2:33:36 PM7/27/19
to vim/vim, vim-dev ML, Your activity

Max Sagebaum

unread,
Jul 27, 2019, 2:39:21 PM7/27/19
to vim/vim, vim-dev ML, Comment

Yes, I can download it there. I am in the progress of compiling.


You are receiving this because you commented.

Max Sagebaum

unread,
Jul 27, 2019, 2:58:27 PM7/27/19
to vim/vim, vim-dev ML, Comment

Yes the patch works. I did the following:

git clone vim
cd vim/src
make
export VIMRUNTIME=/usr/share/vim/vim81
./vim option.c
<verified that I see the blinking/screen redraw>
patch -p2 < sign_refresh.diff
make
./vim option.c
<verified that the blinking/screen redraw no longer happens>

The patch did not apply on the master cleanly. The changes in the options I had to do manually. Here is my diff:
sign_refresh_master.txt


You are receiving this because you commented.

Yegappan Lakshmanan

unread,
Jul 27, 2019, 3:06:06 PM7/27/19
to vim_dev, reply+ACY5DGCF4V2MRQOZPN...@reply.github.com, vim/vim, vim-dev ML, Comment
Hi,

On Sat, Jul 27, 2019 at 11:58 AM Max Sagebaum <vim-dev...@256bit.org> wrote:
>
> Yes the patch works. I did the following:
>

Thanks for validating the fix. I will create a PR.

Regards,
Yegappan

vim-dev ML

unread,
Jul 27, 2019, 3:06:32 PM7/27/19
to vim/vim, vim-dev ML, Your activity

Max Sagebaum

unread,
Aug 1, 2019, 3:06:55 AM8/1/19
to vim/vim, vim-dev ML, Comment

You are welcome, which vim release will have the patch and when will it probably come out?


You are receiving this because you commented.

Yegappan Lakshmanan

unread,
Aug 3, 2019, 1:46:06 AM8/3/19
to vim_dev, reply+ACY5DGD3OSHTOXRVDT...@reply.github.com, vim/vim, vim-dev ML, Comment
Hi,

On Thu, Aug 1, 2019 at 12:06 AM Max Sagebaum <vim-dev...@256bit.org> wrote:
>
> You are welcome, which vim release will have the patch and when will it probably come out?
>

Even though my patch fixed the screen refresh issue in your case, if you
set the 'signcolumn' option to 'number', then you will still see the issue.
I am looking into fixing this case also. As soon as I have a fix for this,
I will create a pull request.

- Yegappan

vim-dev ML

unread,
Aug 3, 2019, 1:46:29 AM8/3/19
to vim/vim, vim-dev ML, Your activity

Yegappan Lakshmanan

unread,
Aug 22, 2019, 4:15:11 PM8/22/19
to vim_dev, reply+ACY5DGD3OSHTOXRVDT...@reply.github.com, vim/vim, vim-dev ML, Comment
Hi,
The fix for this has been merged today through 8.1.1910. Can you try
this version and check whether the problem is addressed?

Thanks,
Yegappan

vim-dev ML

unread,
Aug 22, 2019, 4:15:36 PM8/22/19
to vim/vim, vim-dev ML, Your activity

Max Sagebaum

unread,
Sep 6, 2019, 2:09:28 AM9/6/19
to vim/vim, vim-dev ML, Comment
Sorry for the late answer. Yes it is now fixed I tried the git version 6f72e90dd843a7342395b31f31c2073a3859869d (8.1.1991)

The fix for this has been merged today through 8.1.1910. Can you trythis version and check whether the problem is addressed?

Thanks,
Yegappan




You are receiving this because you commented.

Christian Brabandt

unread,
Sep 6, 2019, 3:59:09 AM9/6/19
to vim/vim, vim-dev ML, Comment

Closed #4697.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages