mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00

When a terminal application running inside the terminal emulator sets the cursor shape or blink status of the cursor, update the cursor in the parent terminal to match. This removes the "virtual cursor" that has been in use by the terminal emulator since the beginning. The original rationale for using the virtual cursor was to avoid having to support additional UI methods to change the cursor color for other (non-TUI) UIs, instead relying on the TermCursor and TermCursorNC highlight groups. The TermCursor highlight group is now used in the default 'guicursor' value, which has a new entry for Terminal mode. However, the TermCursorNC highlight group is no longer supported: since terminal windows now use the real cursor, when the window is not focused there is no cursor displayed in the window at all, so there is nothing to highlight. Users can still use the StatusLineTermNC highlight group to differentiate non-focused terminal windows. BREAKING CHANGE: The TermCursorNC highlight group is no longer supported.
129 lines
4.2 KiB
Lua
129 lines
4.2 KiB
Lua
local t = require('test.testutil')
|
|
local n = require('test.functional.testnvim')()
|
|
|
|
local tt = require('test.functional.testterm')
|
|
local assert_alive = n.assert_alive
|
|
local clear = n.clear
|
|
local feed = n.feed
|
|
local feed_command = n.feed_command
|
|
local command = n.command
|
|
local eq = t.eq
|
|
local eval = n.eval
|
|
local api = n.api
|
|
local sleep = vim.uv.sleep
|
|
local retry = t.retry
|
|
local is_os = t.is_os
|
|
|
|
describe(':terminal', function()
|
|
local screen
|
|
|
|
before_each(function()
|
|
clear()
|
|
-- set the statusline to a constant value because of variables like pid
|
|
-- and current directory and to improve visibility of splits
|
|
api.nvim_set_option_value('statusline', '==========', {})
|
|
screen = tt.setup_screen(3)
|
|
command('highlight StatusLine NONE')
|
|
command('highlight StatusLineNC NONE')
|
|
command('highlight StatusLineTerm NONE')
|
|
command('highlight StatusLineTermNC NONE')
|
|
command('highlight VertSplit NONE')
|
|
end)
|
|
|
|
it('next to a closing window', function()
|
|
command('split')
|
|
command('terminal')
|
|
command('vsplit foo')
|
|
eq(3, eval("winnr('$')"))
|
|
feed('ZQ') -- Close split, should not crash. #7538
|
|
assert_alive()
|
|
end)
|
|
|
|
it('does not change size on WinEnter', function()
|
|
feed('<c-\\><c-n>')
|
|
feed('k')
|
|
feed_command('2split')
|
|
screen:expect([[
|
|
^tty ready |
|
|
rows: 5, cols: 50 |
|
|
========== |
|
|
tty ready |
|
|
rows: 5, cols: 50 |
|
|
|
|
|
|*2
|
|
========== |
|
|
:2split |
|
|
]])
|
|
feed_command('wincmd p')
|
|
screen:expect([[
|
|
tty ready |
|
|
rows: 5, cols: 50 |
|
|
========== |
|
|
^tty ready |
|
|
rows: 5, cols: 50 |
|
|
|
|
|
|*2
|
|
========== |
|
|
:wincmd p |
|
|
]])
|
|
end)
|
|
|
|
it('does not change size if updated when not visible in any window #19665', function()
|
|
local channel = api.nvim_get_option_value('channel', {})
|
|
command('enew')
|
|
sleep(100)
|
|
api.nvim_chan_send(channel, 'foo')
|
|
sleep(100)
|
|
command('bprevious')
|
|
screen:expect([[
|
|
tty ready |
|
|
^foo |
|
|
|*8
|
|
]])
|
|
end)
|
|
|
|
it('forwards resize request to the program', function()
|
|
feed([[<C-\><C-N>G]])
|
|
local w1, h1 = screen._width - 3, screen._height - 2
|
|
local w2, h2 = w1 - 6, h1 - 3
|
|
|
|
if is_os('win') then
|
|
-- win: SIGWINCH is unreliable, use a weaker test. #7506
|
|
retry(3, 30000, function()
|
|
screen:try_resize(w1, h1)
|
|
screen:expect { any = 'rows: 7, cols: 47' }
|
|
screen:try_resize(w2, h2)
|
|
screen:expect { any = 'rows: 4, cols: 41' }
|
|
end)
|
|
return
|
|
end
|
|
|
|
screen:try_resize(w1, h1)
|
|
screen:expect([[
|
|
tty ready |
|
|
rows: 7, cols: 47 |
|
|
|
|
|
|*3
|
|
^ |
|
|
|
|
|
]])
|
|
screen:try_resize(w2, h2)
|
|
screen:expect([[
|
|
tty ready |
|
|
rows: 7, cols: 47 |
|
|
rows: 4, cols: 41 |
|
|
^ |
|
|
|
|
|
]])
|
|
end)
|
|
|
|
it('stays in terminal mode with <Cmd>wincmd', function()
|
|
command('terminal')
|
|
command('split')
|
|
command('terminal')
|
|
feed('a<Cmd>wincmd j<CR>')
|
|
eq(2, eval('winnr()'))
|
|
eq('t', eval('mode(1)'))
|
|
end)
|
|
end)
|