-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vim background color renders incorrectly #832
Comments
The common fix is to disable Vim's "Background Color Erase (BCE)" option by setting t_ut to an empty string, like this: :set t_ut="" This tells Vim to erase areas of the screen, as it does when back-scrolling, using the current background color (from the Vim color scheme) instead of relying on that specific Terminal's implementation of Background Color Erase (BCE) mode. Otherwise, areas are simply erased without regard for background color, which means the Terminal's DEFAULT background value would be used. |
Thanks for the pointer @xtremeperf, that does work around the issue. Although I still see flashes of the wrong background color during scrolling with something like vim-smooth-scroll which scrolls line-by-line rapidly. As I understand it, Vim expects the terminal to support BCE (thus setting |
Exactly. Well, it can also happen if Also, to prevent those flashes of the wrong bg color during rapid scrolling when bce mode is disabled, you'll want to additionally configure the maximum number of lines that vim will scroll before redrawing the screen. Set it to 1 line. The following works well placed in a vimrc file:
I'm think Microsoft/WSL #1706 was maybe an end-of-line/newline erase bug or something like that, but Microsoft/Terminal #70 sounds like the same Vim bce issue we're discussing here. |
On Windows 10 1903 (18362.175) with WSL Ubuntu 18.04, the @xtremeperf workarounds involving
When in vim, this sets the text color to black and the background color to lightgrey. Other colors are listed in /usr/share/vim/vim80/rgb.txt Not all those colors are supported on a 256 color xterm. |
Note that you are setting the background to color |
This looks very similar to issue #70 - might be a duplicate. What is happening when you scroll, is you get a delete lines (DL) or insert lines (IL) escape sequence, which should fill the new space with the current background color, but it doesn't work correctly when using colors from the 256-color palette or RGB mode. A simple test case would be something like this:
That sets a scroll region of 10 lines, and then erases those 10 lines with a green background color from the 256-color palette. While the
The reason for the failure can be found in the That said, the Assuming the |
I installed Windows Terminal 0.3 from Store and start bash shell using default profile If I setup CMD reverse (fg 242, bg 12) and start But when you set app Ubuntu 18.04 Ubuntu window/command properties same values, vim insert mode add black background. |
* This fixes #832 by not mucking with roundtripping attributes. Still needs a test * Add a test * Lets just make this test test everything @miniksa https://media0.giphy.com/media/d7mMzaGDYkz4ZBziP6/giphy.gif * Remove dead code
* This fixes #832 by not mucking with roundtripping attributes. Still needs a test * Add a test * Lets just make this test test everything @miniksa https://media0.giphy.com/media/d7mMzaGDYkz4ZBziP6/giphy.gif * Remove dead code (cherry picked from commit bac69f7)
🎉This issue was addressed in #2668, which has now been successfully released as Handy links: |
Thanks to @xtremeperf, those flashes has been disappeared by adding
on .vimrc. But when I use vim on tmux, the flashes are appeard again. Does somebody know how should I fix it? |
This issue should be reopened as it is NOT resolved. |
@evprkr This was a pretty specific issue with a specific root cause back in 2019. If you're seeing something similar, then the best thing to do would be to open a new issue so we can help diagnose the (new) issue you're seeing. |
https://vi.stackexchange.com/questions/17464/24-bit-256-colorscheme-in-windows-console |
if &term == 'win32'
"" https://github.com/microsoft/terminal/issues/4335
let &t_SI="\<CSI>5\ q"
let &t_SR="\<CSI>7\ q"
"let &t_EI="\<CSI>2\ q"
"" https://github.com/microsoft/terminal/issues/832
set t_ut= | set ttyscroll=1
endif |
I had to find out about this the bad way :) It worked for me too! |
Your Windows build number: (Type
ver
at a Windows Command Prompt)Microsoft Windows [Version 10.0.18362.86]
What you're doing and what's happening: (Copy & paste specific commands and their output, or include screen shots)
In conhost or Windows Terminal, using both Vim.exe and WSL Vim, background color rendering becomes broken if a background color >16 or true colors is used.
With an example file, e.g. https://github.com/GilbertsHub/web-utils/blob/master/cgibinIntercept.sh:
In general it is much easier to reproduce in WSL than Vim.exe, because it doesn't seem to occur after the initial scroll on Vim.exe and the effects are a bit different as described below. I can reproduce with any combination of conhost/terminal and Vim 8.1.883 on Ubuntu/8.0 on Debian/8.1 on Win32. Does not reproduce with neovim (v0.4.0-430-g8698830cb).
A few cases of example behavior:
Same behavior in the new terminal.
Vim.exe on conhost cmd.exe installed from https://github.com/vim/vim-win32-installer/releases/download/v8.1.1099/gvim_8.1.1099_x64.exe
Background color is wrong on the text part but correct otherwise (purple, although this seems to depend on active colorscheme) but is fixed after a Ctrl-L redraw.
Vim.exe on Terminal cmd.exe, same as above
Background color is again wrong, but the background highlight completely disappears after a Ctrl-L redraw.
Background rendered the whole width of the window, e.g. in wsltty:
The effect is very similar to the issue #375, however that one happens with bg color set to <16 (
darkBlue
). However I cannot reproduce that issue anymore, including the terminal bg change.The issues for Win32 and Linux versions might be separate, since their effects are pretty different as described above.
I also haven't been able to reproduce this using VT sequences, but I hope the bug report is still useful.
The text was updated successfully, but these errors were encountered: