neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit e86ccdbeaefd56398bfe7e5927e076348733a868
parent 1fe1b2525f7e54dee17a3303e2a2f1f184ef5493
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 26 Feb 2026 10:06:34 +0800

test: remove remaining use of feed_command() in terminal/ (#38069)

Also deduplicate screen lines in some other tests.
Diffstat:
Mtest/functional/plugin/health_spec.lua | 3+--
Mtest/functional/plugin/lsp/codelens_spec.lua | 3+--
Mtest/functional/terminal/buffer_spec.lua | 16+++++-----------
Mtest/functional/terminal/cursor_spec.lua | 3+--
Mtest/functional/terminal/ex_terminal_spec.lua | 67+++++++++++++++++++++++++++++--------------------------------------
Mtest/functional/terminal/window_spec.lua | 3+--
Mtest/functional/terminal/window_split_tab_spec.lua | 18+++++++-----------
Mtest/functional/ui/decorations_spec.lua | 3+--
Mtest/functional/ui/highlight_spec.lua | 3+--
Mtest/functional/ui/hlstate_spec.lua | 9+++------
Mtest/functional/ui/linematch_spec.lua | 6++----
Mtest/functional/ui/messages2_spec.lua | 12+++---------
12 files changed, 55 insertions(+), 91 deletions(-)

diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua @@ -429,8 +429,7 @@ describe(':checkhealth window', function() checkhealth: checks done | ## grid 4 ^ | - | - | + |*2 test_plug. | success1: | ✅ | diff --git a/test/functional/plugin/lsp/codelens_spec.lua b/test/functional/plugin/lsp/codelens_spec.lua @@ -54,8 +54,7 @@ describe('vim.lsp.codelens', function() ; | println!("S.a: {}, S.b: {}", s.a, s.b); | } | - | - | + |*2 ]]) local grid_without_lenses = dedent([[ diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua @@ -114,9 +114,7 @@ describe(':terminal buffer', function() screen:expect([[ ^tty ready | appended tty ready |*2 - | - |*2 - | + |*4 ]]) -- operator count is also taken into consideration feed('3"ap') @@ -134,8 +132,7 @@ describe(':terminal buffer', function() screen:expect([[ ^tty ready | appended tty ready | - | - |*3 + |*4 :put a | ]]) -- line argument is only used to move the cursor @@ -143,8 +140,7 @@ describe(':terminal buffer', function() screen:expect([[ tty ready | appended tty ready |*2 - | - | + |*2 ^ | :6put a | ]]) @@ -280,8 +276,7 @@ describe(':terminal buffer', function() feed [[:let g:x = 17]] screen:expect([[ tty ready | - | - |*4 + |*5 :let g:x = 17^ | ]]) @@ -341,8 +336,7 @@ describe(':terminal buffer', function() screen:expect(([[ tty ready | ^%s%s| - |*4 - | + |*5 ]]):format(('j'):rep(i), (' '):rep(50 - i))) end feed('l') -- No partial mapping, so all pending refreshes should be processed diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua @@ -290,8 +290,7 @@ describe(':terminal cursor', function() screen:expect({ grid = [[ tty ready | - | - |*4 + |*5 {5:-- TERMINAL --} | ]], condition = function() diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua @@ -6,7 +6,7 @@ local assert_alive = n.assert_alive local clear, poke_eventloop = n.clear, n.poke_eventloop local testprg, source, eq, neq = n.testprg, n.source, t.eq, t.neq local feed = n.feed -local feed_command, eval = n.feed_command, n.eval +local eval = n.eval local fn = n.fn local api = n.api local exec_lua = n.exec_lua @@ -41,7 +41,7 @@ describe(':terminal', function() retry(nil, 4000, function() ok(fn.line('$') > 6) end) - feed_command('messages') + feed(':messages<CR>') screen:expect([[ msg1 | msg2 | @@ -53,35 +53,35 @@ describe(':terminal', function() it('reads output buffer on terminal reporting #4151', function() skip(is_ci('cirrus') or is_os('win')) if is_os('win') then - feed_command( + command( [[terminal powershell -NoProfile -NoLogo -Command Write-Host -NoNewline "\"$([char]27)[6n\""; Start-Sleep -Milliseconds 500 ]] ) else - feed_command([[terminal printf '\e[6n'; sleep 0.5 ]]) + command([[terminal printf '\e[6n'; sleep 0.5 ]]) end screen:expect { any = '%^%[%[1;1R' } end) it('in normal-mode :split does not move cursor', function() if is_os('win') then - feed_command( + command( [[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]] ) else - feed_command([[terminal while true; do echo foo; sleep .1; done]]) + command([[terminal while true; do echo foo; sleep .1; done]]) end feed([[<C-\><C-N>M]]) -- move cursor away from last line poke_eventloop() eq(3, eval("line('$')")) -- window height eq(2, eval("line('.')")) -- cursor is in the middle - feed_command('vsplit') + feed(':vsplit<CR>') eq(2, eval("line('.')")) -- cursor stays where we put it - feed_command('split') + feed(':split<CR>') eq(2, eval("line('.')")) -- cursor stays where we put it end) it('Enter/Leave does not increment jumplist #3723', function() - feed_command('terminal') + feed(':terminal<CR>') local function enter_and_leave() local lines_before = fn.line('$') -- Create a new line (in the shell). For a normal buffer this @@ -212,63 +212,56 @@ local function test_terminal_with_fake_shell(backslash) it('with no argument, acts like jobstart(…,{term=true})', function() command('autocmd! nvim.terminal TermClose') - feed_command('terminal') + command('terminal') screen:expect([[ ^ready $ | [Process exited 0] | - | - :terminal | + |*2 ]]) end) it("with no argument, and 'shell' is set to empty string", function() api.nvim_set_option_value('shell', '', {}) - feed_command('terminal') - screen:expect([[ - ^ | - ~ |*2 - E91: 'shell' option is empty | - ]]) + eq("Vim(terminal):E91: 'shell' option is empty", t.pcall_err(command, 'terminal')) end) it("with no argument, but 'shell' has arguments, acts like jobstart(…,{term=true})", function() api.nvim_set_option_value('shell', shell_path .. ' INTERACT', {}) - feed_command('terminal') + command('terminal') screen:expect([[ ^interact $ | - |*2 - :terminal | + |*3 ]]) end) it('executes a given command through the shell', function() - feed_command('terminal echo hi') + command('terminal echo hi') screen:expect([[ ^ready $ echo hi | | [Process exited 0] | - :terminal echo hi | + | ]]) end) it("executes a given command through the shell, when 'shell' has arguments", function() api.nvim_set_option_value('shell', shell_path .. ' -t jeff', {}) - feed_command('terminal echo hi') + command('terminal echo hi') screen:expect([[ ^jeff $ echo hi | | [Process exited 0] | - :terminal echo hi | + | ]]) end) it('allows quotes and slashes', function() - feed_command([[terminal echo 'hello' \ "world"]]) + command([[terminal echo 'hello' \ "world"]]) screen:expect([[ ^ready $ echo 'hello' \ "world" | | [Process exited 0] | - :terminal echo 'hello' \ "world" | + | ]]) end) @@ -282,7 +275,7 @@ local function test_terminal_with_fake_shell(backslash) it('ignores writes if the backing stream closes', function() command('autocmd! nvim.terminal TermClose') - feed_command('terminal') + command('terminal') feed('iiXXXXXXX') poke_eventloop() -- Race: Though the shell exited (and streams were closed by SIGCHLD @@ -294,23 +287,22 @@ local function test_terminal_with_fake_shell(backslash) it('works with findfile()', function() command('autocmd! nvim.terminal TermClose') - feed_command('terminal') + command('terminal') eq('term://', string.match(eval('bufname("%")'), '^term://')) eq('Xsomedir/Xuniquefile', eval('findfile("Xsomedir/Xuniquefile", ".")')) end) it('works with :find', function() command('autocmd! nvim.terminal TermClose') - feed_command('terminal') + command('terminal') screen:expect([[ ^ready $ | [Process exited 0] | - | - :terminal | + |*2 ]]) eq('term://', string.match(eval('bufname("%")'), '^term://')) feed([[<C-\><C-N>]]) - feed_command([[find */Xuniquefile]]) + command([[find */Xuniquefile]]) if is_os('win') then eq('Xsomedir\\Xuniquefile', eval('bufname("%")')) else @@ -319,12 +311,12 @@ local function test_terminal_with_fake_shell(backslash) end) it('works with gf', function() - feed_command([[terminal echo "Xsomedir/Xuniquefile"]]) + command([[terminal echo "Xsomedir/Xuniquefile"]]) screen:expect([[ ^ready $ echo "Xsomedir/Xuniquefile" | | [Process exited 0] | - :terminal echo "Xsomedir/Xuniquefile" | + | ]]) feed([[<C-\><C-N>]]) eq('term://', string.match(eval('bufname("%")'), '^term://')) @@ -348,12 +340,11 @@ local function test_terminal_with_fake_shell(backslash) it(('with updatetime=%d'):format(ut), function() api.nvim_set_option_value('updatetime', ut, {}) api.nvim_set_option_value('shellcmdflag', 'EXIT', {}) - feed_command('terminal 42') + command('terminal 42') screen:expect([[ ^ | [Process exited 42] | - | - :terminal 42 | + |*2 ]]) end) end diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua @@ -229,8 +229,7 @@ describe(':terminal window', function() line2 | line3 | line4 | - | - | + |*2 ]]) end) end) diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua @@ -5,7 +5,6 @@ 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 @@ -42,29 +41,27 @@ describe(':terminal', function() it('does not change size on WinEnter', function() feed('<c-\\><c-n>') feed('k') - feed_command('2split') + command('2split') screen:expect([[ ^tty ready | rows: 5, cols: 50 | ========== | tty ready | rows: 5, cols: 50 | - | - |*2 + |*3 ========== | - :2split | + | ]]) - feed_command('wincmd p') + command('wincmd p') screen:expect([[ tty ready | rows: 5, cols: 50 | ========== | ^tty ready | rows: 5, cols: 50 | - | - |*2 + |*3 ========== | - :wincmd p | + | ]]) end) @@ -102,8 +99,7 @@ describe(':terminal', function() screen:expect([[ tty ready | rows: 7, cols: 47 | - | - |*3 + |*4 ^ | | ]]) diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua @@ -3055,8 +3055,7 @@ describe('extmark decorations', function() colpos = colpos+1 | end | en^d | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua @@ -673,8 +673,7 @@ describe('highlight', function() {1: }{2:01}{3:234 67}{2:89}{5: }| {4:~ }|*2 {7:[No Name] [+] }| - {1: }{6:-----------------------}| - {1: }{6:-----------------------}| + {1: }{6:-----------------------}|*2 {1: } | {8:[No Name] }| | diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua @@ -227,8 +227,7 @@ describe('ext_hlstate detailed highlights', function() command(("enew | call jobstart(['%s'],{'term':v:true})"):format(testprg('tty-test'))) screen:expect([[ ^tty ready | - | - |*5 + |*6 {7: }| ]]) @@ -242,16 +241,14 @@ describe('ext_hlstate detailed highlights', function() screen:expect([[ ^tty ready | x {5:y z} | - | - |*4 + |*5 {7: }| ]]) else screen:expect([[ ^tty ready | x {2:y }{3:z} | - | - |*4 + |*5 {7: }| ]]) end diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua @@ -557,8 +557,7 @@ something {7: }{8: 11 }^common line │{7: }{8: 14 }common line | {7: }{8: }{23:-------------------------------------------}│{7: }{8: 15 }{22:DEF }| {7: }{8: 12 }something │{7: }{8: 16 }something | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*2 {3:Xtest-functional-diff-screen-1.2 }{2:Xtest-functional-diff-screen-1 [+] }| :e | ]]) @@ -584,8 +583,7 @@ something {7: }{8: }{23:-------------------------------------------}│{7: }{8: 14 }{22:DEF }| {7: }{8: 11 }common line │{7: }{8: 15 }common line | {7: }{8: 12 }^something │{7: }{8: 16 }something | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*2 {3:Xtest-functional-diff-screen-1.2 }{2:Xtest-functional-diff-screen-1 [+] }| :e | ]]) diff --git a/test/functional/ui/messages2_spec.lua b/test/functional/ui/messages2_spec.lua @@ -225,9 +225,7 @@ describe('messages2', function() command('echo "foo"') screen:expect([[ ^ | - {1:~ }|*10 - {1:~ }| - {1:~ }| + {1:~ }|*12 {1:~ }{4:foo}| ]]) command('mode') @@ -239,9 +237,7 @@ describe('messages2', function() command('echo "foo"') screen:expect([[ ^ | - {1:~ }|*10 - {1:~ }| - {1:~ }| + {1:~ }|*12 {1:~ }{4:foo}| ]]) command('echo ""') @@ -250,9 +246,7 @@ describe('messages2', function() screen:try_resize(screen._width, screen._height - 1) screen:expect([[ ^ | - {1:~ }|*9 - {1:~ }| - {1:~ }| + {1:~ }|*11 {1:~ }{4:foo}| ]]) -- Moved up when opening cmdline