mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 21:25:04 -07:00
Compare commits
1 Commits
527b8fb243
...
1960f4df0d
Author | SHA1 | Date | |
---|---|---|---|
|
1960f4df0d |
@ -641,6 +641,9 @@ bool terminal_enter(void)
|
|||||||
curwin->w_p_so = 0;
|
curwin->w_p_so = 0;
|
||||||
curwin->w_p_siso = 0;
|
curwin->w_p_siso = 0;
|
||||||
|
|
||||||
|
// Save the existing cursor entry since it may be modified by the application
|
||||||
|
cursorentry_T save_cursorentry = shape_table[SHAPE_IDX_TERM];
|
||||||
|
|
||||||
// Update the cursor shape table and flush changes to the UI
|
// Update the cursor shape table and flush changes to the UI
|
||||||
s->term->pending.cursor = true;
|
s->term->pending.cursor = true;
|
||||||
refresh_cursor(s->term);
|
refresh_cursor(s->term);
|
||||||
@ -671,8 +674,8 @@ bool terminal_enter(void)
|
|||||||
RedrawingDisabled = s->save_rd;
|
RedrawingDisabled = s->save_rd;
|
||||||
apply_autocmds(EVENT_TERMLEAVE, NULL, NULL, false, curbuf);
|
apply_autocmds(EVENT_TERMLEAVE, NULL, NULL, false, curbuf);
|
||||||
|
|
||||||
// Restore the terminal cursor to what is set in 'guicursor'
|
shape_table[SHAPE_IDX_TERM] = save_cursorentry;
|
||||||
(void)parse_shape_opt(SHAPE_CURSOR);
|
ui_mode_info_set();
|
||||||
|
|
||||||
if (save_curwin == curwin->handle) { // Else: window was closed.
|
if (save_curwin == curwin->handle) { // Else: window was closed.
|
||||||
curwin->w_p_cul = save_w_p_cul;
|
curwin->w_p_cul = save_w_p_cul;
|
||||||
|
@ -15,20 +15,9 @@ local skip = t.skip
|
|||||||
describe(':terminal cursor', function()
|
describe(':terminal cursor', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
local terminal_mode_idx ---@type number
|
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
screen = tt.setup_screen()
|
screen = tt.setup_screen()
|
||||||
|
|
||||||
if terminal_mode_idx == nil then
|
|
||||||
for i, v in ipairs(screen._mode_info) do
|
|
||||||
if v.name == 'terminal' then
|
|
||||||
terminal_mode_idx = i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
assert(terminal_mode_idx)
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('moves the screen cursor when focused', function()
|
it('moves the screen cursor when focused', function()
|
||||||
@ -154,6 +143,13 @@ describe(':terminal cursor', function()
|
|||||||
|
|
||||||
it('can be modified by application #3681', function()
|
it('can be modified by application #3681', function()
|
||||||
skip(is_os('win'), '#31587')
|
skip(is_os('win'), '#31587')
|
||||||
|
local idx ---@type number
|
||||||
|
for i, v in ipairs(screen._mode_info) do
|
||||||
|
if v.name == 'terminal' then
|
||||||
|
idx = i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert(idx)
|
||||||
|
|
||||||
local states = {
|
local states = {
|
||||||
[1] = { blink = true, shape = 'block' },
|
[1] = { blink = true, shape = 'block' },
|
||||||
@ -175,13 +171,13 @@ describe(':terminal cursor', function()
|
|||||||
]],
|
]],
|
||||||
condition = function()
|
condition = function()
|
||||||
if v.blink then
|
if v.blink then
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
|
eq(500, screen._mode_info[idx].blinkon)
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
|
eq(500, screen._mode_info[idx].blinkoff)
|
||||||
else
|
else
|
||||||
eq(0, screen._mode_info[terminal_mode_idx].blinkon)
|
eq(0, screen._mode_info[idx].blinkon)
|
||||||
eq(0, screen._mode_info[terminal_mode_idx].blinkoff)
|
eq(0, screen._mode_info[idx].blinkoff)
|
||||||
end
|
end
|
||||||
eq(v.shape, screen._mode_info[terminal_mode_idx].cursor_shape)
|
eq(v.shape, screen._mode_info[idx].cursor_shape)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -195,13 +191,20 @@ describe(':terminal cursor', function()
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
-- Cursor returns to default on TermLeave
|
-- Cursor returns to default on TermLeave
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
|
eq(500, screen._mode_info[idx].blinkon)
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
|
eq(500, screen._mode_info[idx].blinkoff)
|
||||||
eq('block', screen._mode_info[terminal_mode_idx].cursor_shape)
|
eq('block', screen._mode_info[idx].cursor_shape)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can be modified per terminal', function()
|
it('can be modified per terminal', function()
|
||||||
skip(is_os('win'), '#31587')
|
skip(is_os('win'), '#31587')
|
||||||
|
local idx ---@type number
|
||||||
|
for i, v in ipairs(screen._mode_info) do
|
||||||
|
if v.name == 'terminal' then
|
||||||
|
idx = i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert(idx)
|
||||||
|
|
||||||
-- Set cursor to vertical bar with blink
|
-- Set cursor to vertical bar with blink
|
||||||
tt.feed_csi('5 q')
|
tt.feed_csi('5 q')
|
||||||
@ -213,9 +216,9 @@ describe(':terminal cursor', function()
|
|||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]],
|
]],
|
||||||
condition = function()
|
condition = function()
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
|
eq(500, screen._mode_info[idx].blinkon)
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
|
eq(500, screen._mode_info[idx].blinkoff)
|
||||||
eq('vertical', screen._mode_info[terminal_mode_idx].cursor_shape)
|
eq('vertical', screen._mode_info[idx].cursor_shape)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -228,9 +231,9 @@ describe(':terminal cursor', function()
|
|||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]],
|
]],
|
||||||
condition = function()
|
condition = function()
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
|
eq(500, screen._mode_info[idx].blinkon)
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
|
eq(500, screen._mode_info[idx].blinkoff)
|
||||||
eq('vertical', screen._mode_info[terminal_mode_idx].cursor_shape)
|
eq('vertical', screen._mode_info[idx].cursor_shape)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -253,9 +256,9 @@ describe(':terminal cursor', function()
|
|||||||
]],
|
]],
|
||||||
condition = function()
|
condition = function()
|
||||||
-- New terminal, cursor resets to defaults
|
-- New terminal, cursor resets to defaults
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
|
eq(500, screen._mode_info[idx].blinkon)
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
|
eq(500, screen._mode_info[idx].blinkoff)
|
||||||
eq('block', screen._mode_info[terminal_mode_idx].cursor_shape)
|
eq('block', screen._mode_info[idx].cursor_shape)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -272,9 +275,9 @@ describe(':terminal cursor', function()
|
|||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]],
|
]],
|
||||||
condition = function()
|
condition = function()
|
||||||
eq(0, screen._mode_info[terminal_mode_idx].blinkon)
|
eq(0, screen._mode_info[idx].blinkon)
|
||||||
eq(0, screen._mode_info[terminal_mode_idx].blinkoff)
|
eq(0, screen._mode_info[idx].blinkoff)
|
||||||
eq('horizontal', screen._mode_info[terminal_mode_idx].cursor_shape)
|
eq('horizontal', screen._mode_info[idx].cursor_shape)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -291,9 +294,9 @@ describe(':terminal cursor', function()
|
|||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]],
|
]],
|
||||||
condition = function()
|
condition = function()
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkon)
|
eq(500, screen._mode_info[idx].blinkon)
|
||||||
eq(500, screen._mode_info[terminal_mode_idx].blinkoff)
|
eq(500, screen._mode_info[idx].blinkoff)
|
||||||
eq('vertical', screen._mode_info[terminal_mode_idx].cursor_shape)
|
eq('vertical', screen._mode_info[idx].cursor_shape)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
@ -323,32 +326,6 @@ describe(':terminal cursor', function()
|
|||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('preserves guicursor value on TermLeave #31612', function()
|
|
||||||
eq(3, screen._mode_info[terminal_mode_idx].hl_id)
|
|
||||||
|
|
||||||
-- Change 'guicursor' while terminal mode is active
|
|
||||||
command('set guicursor+=t:Error')
|
|
||||||
|
|
||||||
local error_hl_id = call('hlID', 'Error')
|
|
||||||
|
|
||||||
screen:expect({
|
|
||||||
condition = function()
|
|
||||||
eq(error_hl_id, screen._mode_info[terminal_mode_idx].hl_id)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Exit terminal mode
|
|
||||||
feed([[<C-\><C-N>]])
|
|
||||||
|
|
||||||
screen:expect([[
|
|
||||||
tty ready |
|
|
||||||
^ |
|
|
||||||
|*5
|
|
||||||
]])
|
|
||||||
|
|
||||||
eq(error_hl_id, screen._mode_info[terminal_mode_idx].hl_id)
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('buffer cursor position is correct in terminal without number column', function()
|
describe('buffer cursor position is correct in terminal without number column', function()
|
||||||
@ -373,6 +350,12 @@ describe('buffer cursor position is correct in terminal without number column',
|
|||||||
}, {
|
}, {
|
||||||
cols = 70,
|
cols = 70,
|
||||||
})
|
})
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[1] = { foreground = 253, background = 11 },
|
||||||
|
[2] = { reverse = true },
|
||||||
|
[3] = { bold = true },
|
||||||
|
[4] = { background = 11 },
|
||||||
|
})
|
||||||
-- Also check for real cursor position, as it is used for stuff like input methods
|
-- Also check for real cursor position, as it is used for stuff like input methods
|
||||||
screen._handle_busy_start = function() end
|
screen._handle_busy_start = function() end
|
||||||
screen._handle_busy_stop = function() end
|
screen._handle_busy_stop = function() end
|
||||||
@ -684,6 +667,13 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
|||||||
}, {
|
}, {
|
||||||
cols = 70,
|
cols = 70,
|
||||||
})
|
})
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[1] = { foreground = 253, background = 11 },
|
||||||
|
[2] = { reverse = true },
|
||||||
|
[3] = { bold = true },
|
||||||
|
[4] = { background = 11 },
|
||||||
|
[7] = { foreground = 130 },
|
||||||
|
})
|
||||||
-- Also check for real cursor position, as it is used for stuff like input methods
|
-- Also check for real cursor position, as it is used for stuff like input methods
|
||||||
screen._handle_busy_start = function() end
|
screen._handle_busy_start = function() end
|
||||||
screen._handle_busy_stop = function() end
|
screen._handle_busy_stop = function() end
|
||||||
|
Loading…
Reference in New Issue
Block a user