mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
Merge pull request #24505 from zeertzjq/backport
Backport to release-0.9
This commit is contained in:
@@ -2328,6 +2328,8 @@ static void cmdpreview_restore_undo(const CpUndoInfo *cp_undoinfo, buf_T *buf)
|
||||
static void cmdpreview_prepare(CpInfo *cpinfo)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
PMap(ptr_t) saved_bufs = MAP_INIT;
|
||||
|
||||
kv_init(cpinfo->buf_info);
|
||||
kv_init(cpinfo->win_info);
|
||||
|
||||
@@ -2339,19 +2341,19 @@ static void cmdpreview_prepare(CpInfo *cpinfo)
|
||||
continue;
|
||||
}
|
||||
|
||||
CpBufInfo cp_bufinfo;
|
||||
cp_bufinfo.buf = buf;
|
||||
if (!pmap_has(ptr_t)(&saved_bufs, buf)) {
|
||||
CpBufInfo cp_bufinfo;
|
||||
cp_bufinfo.buf = buf;
|
||||
cp_bufinfo.save_b_p_ul = buf->b_p_ul;
|
||||
cp_bufinfo.save_b_changed = buf->b_changed;
|
||||
cp_bufinfo.save_changedtick = buf_get_changedtick(buf);
|
||||
cmdpreview_save_undo(&cp_bufinfo.undo_info, buf);
|
||||
kv_push(cpinfo->buf_info, cp_bufinfo);
|
||||
pmap_put(ptr_t)(&saved_bufs, buf, NULL);
|
||||
|
||||
cp_bufinfo.save_b_p_ul = buf->b_p_ul;
|
||||
cp_bufinfo.save_b_changed = buf->b_changed;
|
||||
cp_bufinfo.save_changedtick = buf_get_changedtick(buf);
|
||||
|
||||
cmdpreview_save_undo(&cp_bufinfo.undo_info, buf);
|
||||
u_clearall(buf);
|
||||
|
||||
kv_push(cpinfo->buf_info, cp_bufinfo);
|
||||
|
||||
buf->b_p_ul = LONG_MAX; // Make sure we can undo all changes
|
||||
u_clearall(buf);
|
||||
buf->b_p_ul = LONG_MAX; // Make sure we can undo all changes
|
||||
}
|
||||
|
||||
CpWinInfo cp_wininfo;
|
||||
cp_wininfo.win = win;
|
||||
@@ -2370,6 +2372,8 @@ static void cmdpreview_prepare(CpInfo *cpinfo)
|
||||
win->w_p_cuc = false; // Disable 'cursorcolumn' so it doesn't mess up the highlights
|
||||
}
|
||||
|
||||
pmap_destroy(ptr_t)(&saved_bufs);
|
||||
|
||||
cpinfo->save_hls = p_hls;
|
||||
cpinfo->save_cmdmod = cmdmod;
|
||||
win_size_save(&cpinfo->save_view);
|
||||
@@ -2426,6 +2430,7 @@ static void cmdpreview_restore_state(CpInfo *cpinfo)
|
||||
// Clear preview highlights.
|
||||
extmark_clear(buf, (uint32_t)cmdpreview_ns, 0, 0, MAXLNUM, MAXCOL);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < cpinfo->win_info.size; i++) {
|
||||
CpWinInfo cp_wininfo = cpinfo->win_info.items[i];
|
||||
win_T *win = cp_wininfo.win;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
local luv = require('luv')
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local thelpers = require('test.functional.terminal.helpers')
|
||||
|
||||
local clear, command, nvim, testprg =
|
||||
helpers.clear, helpers.command, helpers.nvim, helpers.testprg
|
||||
@@ -8,6 +9,7 @@ local eval, eq, neq, retry =
|
||||
local matches = helpers.matches
|
||||
local ok = helpers.ok
|
||||
local feed = helpers.feed
|
||||
local meths = helpers.meths
|
||||
local pcall_err = helpers.pcall_err
|
||||
local assert_alive = helpers.assert_alive
|
||||
local skip = helpers.skip
|
||||
@@ -162,3 +164,21 @@ it('autocmd TermEnter, TermLeave', function()
|
||||
},
|
||||
eval('g:evs'))
|
||||
end)
|
||||
|
||||
describe('autocmd TextChangedT', function()
|
||||
clear()
|
||||
local screen = thelpers.screen_setup()
|
||||
|
||||
it('works', function()
|
||||
command('autocmd TextChangedT * ++once let g:called = 1')
|
||||
thelpers.feed_data('a')
|
||||
retry(nil, nil, function() eq(1, meths.get_var('called')) end)
|
||||
end)
|
||||
|
||||
it('cannot delete terminal buffer', function()
|
||||
command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]])
|
||||
thelpers.feed_data('a')
|
||||
screen:expect({any = 'E937: '})
|
||||
matches('^E937: Attempt to delete a buffer that is in use: term://', meths.get_vvar('errmsg'))
|
||||
end)
|
||||
end)
|
||||
|
@@ -24,8 +24,7 @@ describe(':terminal buffer', function()
|
||||
|
||||
before_each(function()
|
||||
clear()
|
||||
feed_command('set modifiable swapfile undolevels=20')
|
||||
poke_eventloop()
|
||||
command('set modifiable swapfile undolevels=20')
|
||||
screen = thelpers.screen_setup()
|
||||
end)
|
||||
|
||||
@@ -198,8 +197,7 @@ describe(':terminal buffer', function()
|
||||
|
||||
it('handles loss of focus gracefully', function()
|
||||
-- Change the statusline to avoid printing the file name, which varies.
|
||||
nvim('set_option', 'statusline', '==========')
|
||||
feed_command('set laststatus=0')
|
||||
nvim('set_option_value', 'statusline', '==========', {})
|
||||
|
||||
-- Save the buffer number of the terminal for later testing.
|
||||
local tbuf = eval('bufnr("%")')
|
||||
@@ -232,8 +230,6 @@ describe(':terminal buffer', function()
|
||||
neq(tbuf, eval('bufnr("%")'))
|
||||
feed_command('quit!') -- Should exit the new window, not the terminal.
|
||||
eq(tbuf, eval('bufnr("%")'))
|
||||
|
||||
feed_command('set laststatus=1') -- Restore laststatus to the default.
|
||||
end)
|
||||
|
||||
it('term_close() use-after-free #4393', function()
|
||||
@@ -413,14 +409,6 @@ describe('on_lines does not emit out-of-bounds line indexes when', function()
|
||||
feed_command('bdelete!')
|
||||
eq('', exec_lua([[return _G.cb_error]]))
|
||||
end)
|
||||
|
||||
it('runs TextChangedT event', function()
|
||||
meths.set_var('called', 0)
|
||||
command('autocmd TextChangedT * ++once let g:called = 1')
|
||||
feed_command('terminal')
|
||||
feed('iaa')
|
||||
eq(1, meths.get_var('called'))
|
||||
end)
|
||||
end)
|
||||
|
||||
it('terminal truncates number of composing characters to 5', function()
|
||||
@@ -440,7 +428,7 @@ describe('terminal input', function()
|
||||
_G.input_data = _G.input_data .. data
|
||||
end })
|
||||
]])
|
||||
command('startinsert')
|
||||
feed('i')
|
||||
poke_eventloop()
|
||||
end)
|
||||
|
||||
|
@@ -6,7 +6,7 @@ local testprg, command = helpers.testprg, helpers.command
|
||||
local nvim_prog = helpers.nvim_prog
|
||||
local eq, eval = helpers.eq, helpers.eval
|
||||
local matches = helpers.matches
|
||||
local feed_command = helpers.feed_command
|
||||
local poke_eventloop = helpers.poke_eventloop
|
||||
local hide_cursor = thelpers.hide_cursor
|
||||
local show_cursor = thelpers.show_cursor
|
||||
local is_os = helpers.is_os
|
||||
@@ -153,7 +153,8 @@ describe('cursor with customized highlighting', function()
|
||||
})
|
||||
screen:attach({rgb=false})
|
||||
command('call termopen(["'..testprg('tty-test')..'"])')
|
||||
feed_command('startinsert')
|
||||
feed('i')
|
||||
poke_eventloop()
|
||||
end)
|
||||
|
||||
it('overrides the default highlighting', function()
|
||||
@@ -187,13 +188,16 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
..[[", "-u", "NONE", "-i", "NONE", "-E", "--cmd", "let @r = ']]..str..[['", ]]
|
||||
-- <Left> and <Right> don't always work
|
||||
..[["--cmd", "cnoremap <C-X> <Left>", "--cmd", "cnoremap <C-O> <Right>"]]..']', 70)
|
||||
-- Also check for real cursor position, as it is used for stuff like input methods
|
||||
screen._handle_busy_start = function() end
|
||||
screen._handle_busy_stop = function() end
|
||||
screen:expect([[
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:{1: } |
|
||||
:{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
end
|
||||
@@ -213,7 +217,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:aaaaaaaa{1: } |
|
||||
:aaaaaaaa{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 9}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -238,7 +242,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:aaaaaa{1:a}a |
|
||||
:aaaaaa{1:^a}a |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 7}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -263,7 +267,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:a{1:a}aaaaaa |
|
||||
:a{1:^a}aaaaaa |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 2}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -294,7 +298,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:µµµµµµµµ{1: } |
|
||||
:µµµµµµµµ{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 17}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -319,7 +323,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:µµµµµµ{1:µ}µ |
|
||||
:µµµµµµ{1:^µ}µ |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 13}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -344,7 +348,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:µ{1:µ}µµµµµµ |
|
||||
:µ{1:^µ}µµµµµµ |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 3}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -377,7 +381,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{1: } |
|
||||
:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 33}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -402,7 +406,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:µ̳µ̳µ̳µ̳µ̳µ̳{1:µ̳}µ̳ |
|
||||
:µ̳µ̳µ̳µ̳µ̳µ̳{1:^µ̳}µ̳ |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 25}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -427,7 +431,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:µ̳{1:µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
|
||||
:µ̳{1:^µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 5}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -446,7 +450,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
end)
|
||||
|
||||
describe('in a line with double-cell multibyte characters and no trailing spaces,', function()
|
||||
skip(is_os('win'), "Encoding problem?")
|
||||
if skip(is_os('win'), "Encoding problem?") then return end
|
||||
|
||||
before_each(function()
|
||||
setup_ex_register('哦哦哦哦哦哦哦哦')
|
||||
@@ -460,7 +464,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:哦哦哦哦哦哦哦哦{1: } |
|
||||
:哦哦哦哦哦哦哦哦{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 25}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -485,7 +489,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:哦哦哦哦哦哦{1:哦}哦 |
|
||||
:哦哦哦哦哦哦{1:^哦}哦 |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 19}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -510,7 +514,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:哦{1:哦}哦哦哦哦哦哦 |
|
||||
:哦{1:^哦}哦哦哦哦哦哦 |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 4}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -537,7 +541,7 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
|
|
||||
|
|
||||
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
:aaaaaaaa {1: } |
|
||||
:aaaaaaaa {1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()'))
|
||||
@@ -564,13 +568,16 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
..[[", "-u", "NONE", "-i", "NONE", "-E", "--cmd", "let @r = ']]..str..[['", ]]
|
||||
-- <Left> and <Right> don't always work
|
||||
..[["--cmd", "cnoremap <C-X> <Left>", "--cmd", "cnoremap <C-O> <Right>"]]..']', 70)
|
||||
-- Also check for real cursor position, as it is used for stuff like input methods
|
||||
screen._handle_busy_start = function() end
|
||||
screen._handle_busy_stop = function() end
|
||||
screen:expect([[
|
||||
{7: 1 } |
|
||||
{7: 2 } |
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:{1: } |
|
||||
{7: 6 }:{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
end
|
||||
@@ -593,7 +600,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:aaaaaaaa{1: } |
|
||||
{7: 6 }:aaaaaaaa{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 9}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -618,7 +625,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:aaaaaa{1:a}a |
|
||||
{7: 6 }:aaaaaa{1:^a}a |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 7}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -643,7 +650,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:a{1:a}aaaaaa |
|
||||
{7: 6 }:a{1:^a}aaaaaa |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 2}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -674,7 +681,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:µµµµµµµµ{1: } |
|
||||
{7: 6 }:µµµµµµµµ{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 17}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -699,7 +706,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:µµµµµµ{1:µ}µ |
|
||||
{7: 6 }:µµµµµµ{1:^µ}µ |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 13}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -724,7 +731,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:µ{1:µ}µµµµµµ |
|
||||
{7: 6 }:µ{1:^µ}µµµµµµ |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 3}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -757,7 +764,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{1: } |
|
||||
{7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 33}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -782,7 +789,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳{1:µ̳}µ̳ |
|
||||
{7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳{1:^µ̳}µ̳ |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 25}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -807,7 +814,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:µ̳{1:µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
|
||||
{7: 6 }:µ̳{1:^µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 5}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -826,7 +833,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
end)
|
||||
|
||||
describe('in a line with double-cell multibyte characters and no trailing spaces,', function()
|
||||
skip(is_os('win'), "Encoding problem?")
|
||||
if skip(is_os('win'), "Encoding problem?") then return end
|
||||
|
||||
before_each(function()
|
||||
setup_ex_register('哦哦哦哦哦哦哦哦')
|
||||
@@ -840,7 +847,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:哦哦哦哦哦哦哦哦{1: } |
|
||||
{7: 6 }:哦哦哦哦哦哦哦哦{1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 25}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -865,7 +872,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:哦哦哦哦哦哦{1:哦}哦 |
|
||||
{7: 6 }:哦哦哦哦哦哦{1:^哦}哦 |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 19}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -890,7 +897,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:哦{1:哦}哦哦哦哦哦哦 |
|
||||
{7: 6 }:哦{1:^哦}哦哦哦哦哦哦 |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
eq({6, 4}, eval('nvim_win_get_cursor(0)'))
|
||||
@@ -917,7 +924,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
{7: 3 } |
|
||||
{7: 4 } |
|
||||
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||
{7: 6 }:aaaaaaaa {1: } |
|
||||
{7: 6 }:aaaaaaaa {1:^ } |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()'))
|
||||
|
@@ -99,7 +99,7 @@ describe(':terminal', function()
|
||||
end)
|
||||
|
||||
it('nvim_get_mode() in :terminal', function()
|
||||
command(':terminal')
|
||||
command('terminal')
|
||||
eq({ blocking=false, mode='nt' }, nvim('get_mode'))
|
||||
feed('i')
|
||||
eq({ blocking=false, mode='t' }, nvim('get_mode'))
|
||||
@@ -108,17 +108,19 @@ describe(':terminal', function()
|
||||
end)
|
||||
|
||||
it(':stopinsert RPC request exits terminal-mode #7807', function()
|
||||
command(':terminal')
|
||||
command('terminal')
|
||||
feed('i[tui] insert-mode')
|
||||
eq({ blocking=false, mode='t' }, nvim('get_mode'))
|
||||
command('stopinsert')
|
||||
feed('<Ignore>') -- Add input to separate two RPC requests
|
||||
eq({ blocking=false, mode='nt' }, nvim('get_mode'))
|
||||
end)
|
||||
|
||||
it(':stopinsert in normal mode doesn\'t break insert mode #9889', function()
|
||||
command(':terminal')
|
||||
command('terminal')
|
||||
eq({ blocking=false, mode='nt' }, nvim('get_mode'))
|
||||
command(':stopinsert')
|
||||
command('stopinsert')
|
||||
feed('<Ignore>') -- Add input to separate two RPC requests
|
||||
eq({ blocking=false, mode='nt' }, nvim('get_mode'))
|
||||
feed('a')
|
||||
eq({ blocking=false, mode='t' }, nvim('get_mode'))
|
||||
|
@@ -5,7 +5,7 @@ local helpers = require('test.functional.helpers')(nil)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local testprg = helpers.testprg
|
||||
local exec_lua = helpers.exec_lua
|
||||
local feed_command, nvim = helpers.feed_command, helpers.nvim
|
||||
local nvim = helpers.nvim
|
||||
|
||||
local function feed_data(data)
|
||||
if type(data) == 'table' then
|
||||
@@ -82,15 +82,16 @@ local function screen_setup(extra_rows, command, cols, opts)
|
||||
|
||||
screen:attach(opts or {rgb=false})
|
||||
|
||||
feed_command('enew | call termopen('..command..')')
|
||||
nvim('command', 'enew | call termopen('..command..')')
|
||||
nvim('input', '<CR>')
|
||||
local vim_errmsg = nvim('eval', 'v:errmsg')
|
||||
if vim_errmsg and "" ~= vim_errmsg then
|
||||
error(vim_errmsg)
|
||||
end
|
||||
|
||||
feed_command('setlocal scrollback=10')
|
||||
feed_command('startinsert')
|
||||
nvim('command', 'setlocal scrollback=10')
|
||||
nvim('command', 'startinsert')
|
||||
nvim('input', '<Ignore>') -- Add input to separate two RPC requests
|
||||
|
||||
-- tty-test puts the terminal into raw mode and echoes input. Tests work by
|
||||
-- feeding termcodes to control the display and asserting by screen:expect.
|
||||
|
@@ -2,7 +2,7 @@ local Screen = require('test.functional.ui.screen')
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local thelpers = require('test.functional.terminal.helpers')
|
||||
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
|
||||
local feed, testprg, feed_command = helpers.feed, helpers.testprg, helpers.feed_command
|
||||
local feed, testprg = helpers.feed, helpers.testprg
|
||||
local eval = helpers.eval
|
||||
local command = helpers.command
|
||||
local matches = helpers.matches
|
||||
@@ -349,8 +349,7 @@ describe(':terminal prints more lines than the screen height and exits', functio
|
||||
clear()
|
||||
local screen = Screen.new(30, 7)
|
||||
screen:attach({rgb=false})
|
||||
feed_command(("call termopen(['%s', '10']) | startinsert"):format(testprg('tty-test')))
|
||||
poke_eventloop()
|
||||
command(("call termopen(['%s', '10']) | startinsert"):format(testprg('tty-test')))
|
||||
screen:expect([[
|
||||
line6 |
|
||||
line7 |
|
||||
|
@@ -8,7 +8,6 @@ local helpers = require('test.functional.helpers')(after_each)
|
||||
local thelpers = require('test.functional.terminal.helpers')
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local eq = helpers.eq
|
||||
local feed_command = helpers.feed_command
|
||||
local feed_data = thelpers.feed_data
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
@@ -109,14 +108,14 @@ describe('TUI', function()
|
||||
end)
|
||||
|
||||
it('accepts resize while pager is active', function()
|
||||
child_session:request("nvim_exec", [[
|
||||
set more
|
||||
func! ManyErr()
|
||||
for i in range(20)
|
||||
echoerr "FAIL ".i
|
||||
endfor
|
||||
endfunc
|
||||
]], false)
|
||||
child_session:request('nvim_exec2', [[
|
||||
set more
|
||||
func! ManyErr()
|
||||
for i in range(20)
|
||||
echoerr "FAIL ".i
|
||||
endfor
|
||||
endfunc
|
||||
]], {})
|
||||
feed_data(':call ManyErr()\r')
|
||||
screen:expect{grid=[[
|
||||
{8:Error detected while processing function ManyErr:} |
|
||||
@@ -240,7 +239,7 @@ describe('TUI', function()
|
||||
it('interprets leading <Esc> byte as ALT modifier in normal-mode', function()
|
||||
local keys = 'dfghjkl'
|
||||
for c in keys:gmatch('.') do
|
||||
feed_command('nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>')
|
||||
feed_data(':nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>\r')
|
||||
feed_data('\027'..c)
|
||||
end
|
||||
screen:expect([[
|
||||
@@ -280,9 +279,11 @@ describe('TUI', function()
|
||||
end)
|
||||
|
||||
it('interprets <Esc>[27u as <Esc>', function()
|
||||
feed_command('nnoremap <M-;> <Nop>')
|
||||
feed_command('nnoremap <Esc> AESC<Esc>')
|
||||
feed_command('nnoremap ; Asemicolon<Esc>')
|
||||
child_session:request('nvim_exec2', [[
|
||||
nnoremap <M-;> <Nop>
|
||||
nnoremap <Esc> AESC<Esc>
|
||||
nnoremap ; Asemicolon<Esc>
|
||||
]], {})
|
||||
feed_data('\027[27u;')
|
||||
screen:expect([[
|
||||
ESCsemicolo{1:n} |
|
||||
@@ -330,11 +331,11 @@ describe('TUI', function()
|
||||
end)
|
||||
|
||||
it('accepts mouse wheel events #19992', function()
|
||||
child_session:request('nvim_exec', [[
|
||||
child_session:request('nvim_exec2', [[
|
||||
set number nostartofline nowrap mousescroll=hor:1,ver:1
|
||||
call setline(1, repeat([join(range(10), '----')], 10))
|
||||
vsplit
|
||||
]], false)
|
||||
]], {})
|
||||
screen:expect([[
|
||||
{11: 1 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
|
||||
{11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----|
|
||||
@@ -660,11 +661,11 @@ describe('TUI', function()
|
||||
|
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
child_session:request('nvim_exec', [[
|
||||
child_session:request('nvim_exec2', [[
|
||||
tab split
|
||||
tabnew
|
||||
highlight Tabline ctermbg=NONE ctermfg=NONE cterm=underline
|
||||
]], false)
|
||||
]], {})
|
||||
screen:expect([[
|
||||
{12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}|
|
||||
{1: } |
|
||||
@@ -719,7 +720,7 @@ describe('TUI', function()
|
||||
end)
|
||||
|
||||
it('mouse events work with right-click menu', function()
|
||||
child_session:request('nvim_exec', [[
|
||||
child_session:request('nvim_exec2', [[
|
||||
call setline(1, 'popup menu test')
|
||||
set mouse=a mousemodel=popup
|
||||
|
||||
@@ -729,7 +730,7 @@ describe('TUI', function()
|
||||
menu PopUp.baz :let g:menustr = 'baz'<CR>
|
||||
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
|
||||
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
|
||||
]], false)
|
||||
]], {})
|
||||
meths.input_mouse('right', 'press', '', 0, 0, 4)
|
||||
screen:expect([[
|
||||
{1:p}opup menu test |
|
||||
@@ -1583,11 +1584,11 @@ describe('TUI', function()
|
||||
it('no stack-use-after-scope with cursor color #22432', function()
|
||||
screen:set_option('rgb', true)
|
||||
command('set termguicolors')
|
||||
child_session:request('nvim_exec', [[
|
||||
child_session:request('nvim_exec2', [[
|
||||
set tgc
|
||||
hi Cursor guifg=Red guibg=Green
|
||||
set guicursor=n:block-Cursor/lCursor
|
||||
]], false)
|
||||
]], {})
|
||||
screen:set_default_attr_ids({
|
||||
[1] = {reverse = true},
|
||||
[2] = {bold = true, foreground = Screen.colors.Blue},
|
||||
@@ -1771,10 +1772,10 @@ describe('TUI FocusGained/FocusLost', function()
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
child_session = helpers.connect(child_server)
|
||||
child_session:request('nvim_exec', [[
|
||||
child_session:request('nvim_exec2', [[
|
||||
autocmd FocusGained * echo 'gained'
|
||||
autocmd FocusLost * echo 'lost'
|
||||
]], false)
|
||||
]], {})
|
||||
feed_data("\034\016") -- CTRL-\ CTRL-N
|
||||
end)
|
||||
|
||||
@@ -1805,7 +1806,7 @@ describe('TUI FocusGained/FocusLost', function()
|
||||
end)
|
||||
|
||||
it('in insert-mode', function()
|
||||
feed_command('set noshowmode')
|
||||
feed_data(':set noshowmode\r')
|
||||
feed_data('i')
|
||||
screen:expect{grid=[[
|
||||
{1: } |
|
||||
@@ -1870,11 +1871,11 @@ describe('TUI FocusGained/FocusLost', function()
|
||||
-- Set up autocmds that modify the buffer, instead of just calling :echo.
|
||||
-- This is how we can test handling of focus gained/lost during cmdline-mode.
|
||||
-- See commit: 5cc87d4dabd02167117be7a978b5c8faaa975419.
|
||||
child_session:request('nvim_exec', [[
|
||||
child_session:request('nvim_exec2', [[
|
||||
autocmd!
|
||||
autocmd FocusLost * call append(line('$'), 'lost')
|
||||
autocmd FocusGained * call append(line('$'), 'gained')
|
||||
]], false)
|
||||
]], {})
|
||||
retry(2, 3 * screen.timeout, function()
|
||||
-- Enter cmdline-mode.
|
||||
feed_data(':')
|
||||
|
@@ -2,7 +2,6 @@ local helpers = require('test.functional.helpers')(after_each)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local curbufmeths = helpers.curbufmeths
|
||||
local eq = helpers.eq
|
||||
local eval = helpers.eval
|
||||
local feed_command = helpers.feed_command
|
||||
@@ -175,11 +174,14 @@ describe(":substitute, 'inccommand' preserves", function()
|
||||
it("'undolevels' (inccommand="..case..")", function()
|
||||
feed_command("set undolevels=139")
|
||||
feed_command("setlocal undolevels=34")
|
||||
feed_command("split") -- Show the buffer in multiple windows
|
||||
feed_command("set inccommand=" .. case)
|
||||
insert("as")
|
||||
feed(":%s/as/glork/<enter>")
|
||||
eq(meths.get_option('undolevels'), 139)
|
||||
eq(curbufmeths.get_option('undolevels'), 34)
|
||||
feed(":%s/as/glork/")
|
||||
poke_eventloop()
|
||||
feed("<enter>")
|
||||
eq(meths.get_option_value('undolevels', {scope='global'}), 139)
|
||||
eq(meths.get_option_value('undolevels', {buf=0}), 34)
|
||||
end)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user