Visual selection cursor cell becomes unreadable in the terminal
Visual selection cursor cell becomes unreadable in the terminal
Problem
After upgrading from Neovim 0.12.5 to Neovim 0.13, the character under the cursor in a Visual selection is rendered differently from the rest of the selection.
This is especially noticeable when the Visual highlight uses reverse = true. The selected characters are readable, but the character at the cursor position becomes hard to read or appears to have a different color.
This seems related to:
vim-patch:9.2.1114- #42105
- the removal of the
noinvcurhandling
Steps to reproduce
- Start Neovim in a terminal.
- Configure Visual mode with reverse video:
vim.opt.termguicolors = true
vim.api.nvim_set_hl(0, "Visual", {
reverse = true,
bg = "#665c54",
})- Enter the following text:
abcd- Enter Visual mode and select the text with
vll
Expected behavior
All selected characters, including the character under the cursor, should remain readable and have the same Visual selection appearance.
Actual behavior
The character under the cursor is rendered differently from the rest of the Visual selection and may become difficult to read.
This did not happen with the same configuration in Neovim 0.12.5.
Workaround
Changing the cursor shape in Visual mode avoids the problem:
:set guicursor=v:hor10-Visualor in Lua:
vim.opt.guicursor = {
"n-c-sm:block-Cursor",
"v:hor10-Visual",
"i-ci-ve:ver25-Cursor",
"r-cr-o:hor20-Cursor",
}Environment
- Neovim version:
0.13.0-dev(previously0.12.5)- OS: Ubuntu 20.04
- Terminal emulator: the default GNOME Terminal shipped with Ubuntu 20.04 (running on Wayland/X11 session, not in tmux)
$TERM:xterm-256color$COLORTERM:truecolor- tmux: no
termguicolors: onguicursor: default (not set)
Additional information
The behavior appears to be related to the interaction between:
- Visual selection using reverse video;
- the terminal drawing the cursor by inverting the cursor cell;
- the new behavior that includes the cursor position in the Visual selection highlighting.
The workaround works by using a horizontal cursor in Visual mode, but it would be preferable if the default terminal rendering did not make the character under the cursor unreadable.
Source: neovim/neovim