martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.2k stars 258 forks source link

Text from wrapped lines remains after editing new files #1010

Open groves opened 2 years ago

groves commented 2 years ago

When I have a file with lines that wrap multiple times and I edit a new file that doesn't have specific text on those lines, the text from the previous file remains. I've only seen this behavior on NixOS. I only recently started using Vis on NixOS, so it's always been Vis 0.7 using a recent version of Vis in nixpkgs like this one.

The simplest repro I've found is to open a tiny terminal with 13 columns and 23 lines and to open this file in vis:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

That wraps like this in vis in that tiny window:

abcdefghijklm
nopqrstuvwxyz
ABCDEFGHIJKLM
NOPQRSTUVWXYZ

abcdefghijklm
nopqrstuvwxyz
ABCDEFGHIJKLM
NOPQRSTUVWXYZ

abcdefghijklm
nopqrstuvwxyz
ABCDEFGHIJKLM
NOPQRSTUVWXYZ

~            
~            
~            
~            
~            
~            

If I then run :e blank, where blank is a non-existent file I get this in vis:


~            
~            
~            
~            
~            
~            
~            
~            
~            
~            
~            
~            
~            
~            
~OPQRSTUVWXYZ
~            
~            
~            
~            

I've enabled UI_DEBUG in compiling vis and can see that the correct space character is being set in all the blank cells. I've added debug printing to ui_curses_blit in ui-terminal-curses.c and have confirmed that the correct space character is being sent to ncurses' mvaddstr. If I call vis:redraw() on WIN_OPEN events in my visrc.lua, the characters from the previous file disappear. If I call ncurses' erase function in ui_curses_blit, the phantom characters remain.

All that together makes me think this is a bug in ncurses' double buffering code, but I'm not sure where to take this from there. I'm running ncurses 6.3 in Nix, but I don't get the same issue with ncurses 6.3 with vis built by homebrew on my Mac.

Any thoughts on next steps I could take to debug this?

rnpnr commented 8 months ago

Hi, I am unable to recreate on current master with or without curses enabled. You will have to try with an updated Nix package. Given that you can't recreate this yourself on macOS it leads me to think its a bug in NixOS.