[vim/vim] Buggy screen refresh in gVim with a Netrw window (#8820)

34 views
Skip to first unread message

Gabriel Dupras

unread,
Aug 30, 2021, 10:10:11 AMAug 30
to vim/vim, Subscribed

Describe the bug
In gVim, when a Netrw window is visible and the screen is refreshed, either
automatically or by doing CTRL-L, gVim twitches and can even change size.

To Reproduce

  1. gvim --clean
  2. :source $VIMRUNTIME/plugin/netrwPlugin.vim
  3. :Sexplore
  4. Do CTRL-L and note how gVim twitches. Elements of the GUI quickly
    disappear and reappear.
  5. :set guioptions=egL
  6. Do CTRL-L several times and note how the gVim window becomes narrower.

Expected behavior
No twitching when the screen is refreshed. gVim window should not change size.

Screenshots
https://user-images.githubusercontent.com/57042631/131352404-440db7f7-4269-4a74-8637-7629371f0e47.mp4

Environment (please complete the following information):

  • Vim 8.2.3386
  • OS: Windows 10
  • Terminal: GUI

Additional context
This bug does not affect Vim 8.2.3384. It also does not affect Vim run in a
terminal.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Gabriel Dupras

unread,
Aug 31, 2021, 8:56:36 PMAug 31
to vim/vim, Subscribed

This bug also affects gVim 8.2.3386 GTK3 on Kubuntu 21.04.

Christian Brabandt

unread,
Sep 1, 2021, 2:49:47 AMSep 1
to vim/vim, Subscribed

Just a guess, but does :set guioptions+=k help?

Gabriel Dupras

unread,
Sep 1, 2021, 9:06:37 AMSep 1
to vim/vim, Subscribed

It does not. With :set guioptions=egLk, I still see the tool bar and the menu bar flicker. The gVim window still gets narrower when the screen is refreshed.

c64cosmin

unread,
Sep 1, 2021, 12:12:37 PMSep 1
to vim/vim, Subscribed

I ran in the same problem, did a git bisect to find the culprit
89a9c15 is the first bad commit.

The way I found out is described below, if this is not related, please let me know to open a new issue.

When I use :Ex the gVim windows flashes the toolbar and gets narrower by one character.
I also use https://www.vim.org/scripts/script.php?script_id=2596 in order to have F11 mapped to full screen(remove the border&titlebar). When I use F11, columns and lines are set to a big value, using :Ex in fullscreen will make gvim.exe run heavily for a minute (full CPU) before it displays the contents of directory.

I also use this script

function ToggleExplorer()
    if &ft == "netrw"
        if exists("w:netrw_rexfile")
            if w:netrw_rexfile == "" || w:netrw_rexfile == "NetrwTreeListing"
                exec 'q'
            else
                exec 'e ' . w:netrw_rexfile
            endif
        else
            if exists("w:netrw_rexlocal")
                Rexplore
            else
                exec 'q'
            endif
        endif
    else
        Explore
    endif
endfun

I use this to open/close the Explorer, with the bug above the script won't work correctly.
The expected result is that calling this function will open explorer, calling it again inside an explorer will close it, or close vim is that is the only buffer.
With the bug, explorer opens, gets narrower, calling the function again will just make the editor narrower.

Also using gvim in Windows 10, compiled using MSVC.

Gabriel Dupras

unread,
Sep 1, 2021, 9:16:21 PMSep 1
to vim/vim, Subscribed

Removing these two lines solved the problem for me:

diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index 5ea8319cf..252d664d6 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -1680,7 +1680,6 @@ fun! s:NetrwOptionsSave(vt)
   endif
   let {a:vt}netrw_fokeep    = &l:fo           " formatoptions
   let {a:vt}netrw_gdkeep    = &l:gd           " gdefault
-  let {a:vt}netrw_gokeep    = &l:go           " guioptions
   let {a:vt}netrw_hidkeep   = &l:hidden
   let {a:vt}netrw_imkeep    = &l:im
   let {a:vt}netrw_iskkeep   = &l:isk
@@ -1832,7 +1831,6 @@ fun! s:NetrwOptionsRestore(vt)
 "  call Decho("(s:NetrwOptionsRestore) #4 lines=".&lines)
   call s:NetrwRestoreSetting(a:vt."netrw_fokeep"   ,"&l:fo")
   call s:NetrwRestoreSetting(a:vt."netrw_gdkeep"   ,"&l:gd")
-  call s:NetrwRestoreSetting(a:vt."netrw_gokeep"   ,"&l:go")
   call s:NetrwRestoreSetting(a:vt."netrw_hidkeep"  ,"&l:hidden")
 "  call Decho("(s:NetrwOptionsRestore) #5 lines=".&lines)
   call s:NetrwRestoreSetting(a:vt."netrw_imkeep"   ,"&l:im")

These two lines were added recently, it 89a9c15. I don't know if this is the right solution though.

K.Takata

unread,
Sep 1, 2021, 9:18:23 PMSep 1
to vim/vim, Subscribed

Cc @cecamp

Gabriel Dupras

unread,
Sep 1, 2021, 9:56:42 PMSep 1
to vim/vim, Subscribed

Christian Brabandt

unread,
Sep 2, 2021, 2:57:07 AMSep 2
to vim/vim, Subscribed

Can you throw in a k into the NetrwSetSafeSetting call?

c64cosmin

unread,
Sep 2, 2021, 4:45:34 AMSep 2
to vim/vim, Subscribed

Removing the
https://github.com/vim/vim/blob/04626c243c47af91c2580eaf23e12286180e0e81/runtime/autoload/netrw.vim#L1754

Does solve the issue on my side.
I am using
guioptions=!c

Bram Moolenaar

unread,
Sep 2, 2021, 6:43:33 AMSep 2
to vim/vim, Subscribed


> Removing these two lines solved the problem for me:
>
> ```diff
> diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
> index 5ea8319cf..252d664d6 100644
> --- a/runtime/autoload/netrw.vim
> +++ b/runtime/autoload/netrw.vim
> @@ -1680,7 +1680,6 @@ fun! s:NetrwOptionsSave(vt)
> endif
> let {a:vt}netrw_fokeep = &l:fo " formatoptions
> let {a:vt}netrw_gdkeep = &l:gd " gdefault
> - let {a:vt}netrw_gokeep = &l:go " guioptions
> let {a:vt}netrw_hidkeep = &l:hidden
> let {a:vt}netrw_imkeep = &l:im
> let {a:vt}netrw_iskkeep = &l:isk
> @@ -1832,7 +1831,6 @@ fun! s:NetrwOptionsRestore(vt)
> " call Decho("(s:NetrwOptionsRestore) #4 lines=".&lines)
> call s:NetrwRestoreSetting(a:vt."netrw_fokeep" ,"&l:fo")
> call s:NetrwRestoreSetting(a:vt."netrw_gdkeep" ,"&l:gd")
> - call s:NetrwRestoreSetting(a:vt."netrw_gokeep" ,"&l:go")
> call s:NetrwRestoreSetting(a:vt."netrw_hidkeep" ,"&l:hidden")
> " call Decho("(s:NetrwOptionsRestore) #5 lines=".&lines)
> call s:NetrwRestoreSetting(a:vt."netrw_imkeep" ,"&l:im")
> ```
>
> These two lines were added recently, it 89a9c15. I don't know if this
> is the right solution though.

'guioptions' is not a local option. It's also set globally in line
1754:

call s:NetrwSetSafeSetting("&go","begmr")

Perhaps you need to delete that line too?

I wonder why it has the "b" flag for bottom scrollbar, doesn't seem
related to netrw at all.

Perhaps some 'guioption' flag is causing trouble, then that flag should
be removed, not the whole option set to a possibly completely different
value.

--
If your company is not involved in something called "ISO 9000" you probably
have no idea what it is. If your company _is_ involved in ISO 9000 then you
definitely have no idea what it is.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Sep 2, 2021, 7:00:52 AMSep 2
to vim/vim, Subscribed

I would guess it's the clipboard handling (e.g. the a and A flags).

cecamp

unread,
Sep 3, 2021, 1:51:50 PMSep 3
to vim/vim, Subscribed

Let me know if v172a helps.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

Gabriel Dupras

unread,
Sep 4, 2021, 11:40:00 AMSep 4
to vim/vim, Subscribed

I've tried v172a but it does not fix this bug.

I've never installed a new version of Netrw before so I'm not entirely sure I did this correctly. I downloaded the netrw.vba.gz file, opened the file in Vim and did :so %. This installed the files in my vimfiles directory (I'm on Windows). I then opened a new instance of gVim, did :Se and the banner displays v172a. So I'm assuming I did install it correctly.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

Gabriel Dupras

unread,
Sep 4, 2021, 10:15:25 PMSep 4
to vim/vim, Subscribed

How about this patch, on top of v172a?

diff --git a/autoload/netrw.vim b/autoload/netrw.vim
index 81f89fc..7ce66d9 100644
--- a/autoload/netrw.vim
+++ b/autoload/netrw.vim
@@ -1751,7 +1751,7 @@ fun! s:NetrwOptionsSafe(islocal)
   if &cpo =~ 'a' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'a','','g')) | endif
   if &cpo =~ 'A' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'A','','g')) | endif
   setl fo=nroql2
-  call s:NetrwSetSafeSetting("&go","egmr")
+  if &go =~ '\ca' | call s:NetrwSetSafeSetting("&go",substitute(&go,'\ca','','g')) | endif
   call s:NetrwSetSafeSetting("&l:hid",0)
   call s:NetrwSetSafeSetting("&l:im",0)
   setl isk+=@ isk+=* isk+=/


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

c64cosmin

unread,
Sep 13, 2021, 10:26:24 AMSep 13
to vim/vim, Subscribed

@gdupras Hello, thank you so much for your reply, the change above does solve my issue on my side.
Adding the other line of code


if &go =~ '\ca' | call s:NetrwSetSafeSetting("&go",substitute(&go,'\ca','','g')) | endif

won't add unexpected behavior in my GUI


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

c64cosmin

unread,
Sep 23, 2021, 11:45:47 AMSep 23
to vim/vim, Subscribed

The fix above also removes flashing of the menu bar in gVim on GNOME too.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

Bram Moolenaar

unread,
Oct 3, 2021, 10:57:23 AM (13 days ago) Oct 3
to vim/vim, Subscribed

Closed #8820.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

Bram Moolenaar

unread,
Oct 3, 2021, 10:57:23 AM (13 days ago) Oct 3
to vim/vim, Subscribed

I'll tentatively include this, I don't know when @cecamp will send a new version.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

cecamp

unread,
Oct 3, 2021, 7:05:03 PM (12 days ago) Oct 3
to vim/vim, Subscribed

I believe that netrw v172c already has this issue fixed. You may get it from my website: http://www.drchip.org/astronaut/vim/index.html


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

Reply all
Reply to author
Forward
0 new messages