From f7c6676199f222162dc4ec448857ac64faa26f87 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 16 Jul 2022 20:35:07 +0800 Subject: vim-patch:8.2.0052: more-prompt not properly tested Problem: More-prompt not properly tested. Solution: Add a test case. (Dominique Pelle, closes vim/vim#5404) https://github.com/vim/vim/commit/c6d539b67181ad573452e919e58ecbfa362f4c49 --- src/nvim/testdir/test_messages.vim | 95 +++++++++ test/functional/legacy/messages_spec.lua | 317 +++++++++++++++++++++++++++---- 2 files changed, 379 insertions(+), 33 deletions(-) diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index 8be0c79499..6954b4bc91 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -112,6 +112,101 @@ func Test_echospace() set ruler& showcmd& endfunc +" Test more-prompt (see :help more-prompt). +func Test_message_more() + if !CanRunVimInTerminal() + throw 'Skipped: cannot run vim in terminal' + endif + let buf = RunVimInTerminal('', {'rows': 6}) + call term_sendkeys(buf, ":call setline(1, range(1, 100))\n") + + call term_sendkeys(buf, ":%p#\n") + call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) + + call term_sendkeys(buf, '?') + call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit ', term_getline(buf, 6))}) + + " Down a line with j, , or . + call term_sendkeys(buf, "j") + call WaitForAssert({-> assert_equal(' 6 6', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_equal(' 7 7', term_getline(buf, 5))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_equal(' 8 8', term_getline(buf, 5))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_equal(' 9 9', term_getline(buf, 5))}) + + " Down a screen with , f, or . + call term_sendkeys(buf, 'f') + call WaitForAssert({-> assert_equal(' 14 14', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) + call term_sendkeys(buf, ' ') + call WaitForAssert({-> assert_equal(' 19 19', term_getline(buf, 5))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_equal(' 24 24', term_getline(buf, 5))}) + + " Down a page (half a screen) with d. + call term_sendkeys(buf, 'd') + call WaitForAssert({-> assert_equal(' 27 27', term_getline(buf, 5))}) + + " Down all the way with 'G'. + call term_sendkeys(buf, 'G') + call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) + + " Up a line k, or . + call term_sendkeys(buf, 'k') + call WaitForAssert({-> assert_equal(' 99 99', term_getline(buf, 5))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_equal(' 98 98', term_getline(buf, 5))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_equal(' 97 97', term_getline(buf, 5))}) + + " Up a screen with b or . + call term_sendkeys(buf, 'b') + call WaitForAssert({-> assert_equal(' 92 92', term_getline(buf, 5))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_equal(' 87 87', term_getline(buf, 5))}) + + " Up a page (half a screen) with u. + call term_sendkeys(buf, 'u') + call WaitForAssert({-> assert_equal(' 84 84', term_getline(buf, 5))}) + + " Up all the way with 'g'. + call term_sendkeys(buf, 'g') + call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) + + " All the way down. Pressing f should do nothing but pressing + " space should end the more prompt. + call term_sendkeys(buf, 'G') + call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) + call term_sendkeys(buf, 'f') + call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) + call term_sendkeys(buf, ' ') + call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))}) + + " Pressing g< shows the previous command output. + call term_sendkeys(buf, 'g<') + call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) + + call term_sendkeys(buf, ":%p#\n") + call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) + + " Stop command output with q, or CTRL-C. + call term_sendkeys(buf, 'q') + call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))}) + + call term_sendkeys(buf, ':q!') + call StopVimInTerminal(buf) +endfunc + func Test_mapping_at_hit_return_prompt() nnoremap :echo "hit ctrl-b" call feedkeys(":ls\", "xt") diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 34807a099c..9fd6090969 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -8,39 +8,290 @@ local feed = helpers.feed before_each(clear) describe('messages', function() - it('more prompt with control characters can be quit vim-patch:8.2.1844', function() - local screen = Screen.new(40, 6) - screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Blue}, -- SpecialKey - [2] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg - [3] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - }) - screen:attach() - command('set more') - feed([[:echom range(9999)->join("\x01")]]) - screen:expect([[ - 0{1:^A}1{1:^A}2{1:^A}3{1:^A}4{1:^A}5{1:^A}6{1:^A}7{1:^A}8{1:^A}9{1:^A}10{1:^A}11{1:^A}12| - {1:^A}13{1:^A}14{1:^A}15{1:^A}16{1:^A}17{1:^A}18{1:^A}19{1:^A}20{1:^A}21{1:^A}22| - {1:^A}23{1:^A}24{1:^A}25{1:^A}26{1:^A}27{1:^A}28{1:^A}29{1:^A}30{1:^A}31{1:^A}32| - {1:^A}33{1:^A}34{1:^A}35{1:^A}36{1:^A}37{1:^A}38{1:^A}39{1:^A}40{1:^A}41{1:^A}42| - {1:^A}43{1:^A}44{1:^A}45{1:^A}46{1:^A}47{1:^A}48{1:^A}49{1:^A}50{1:^A}51{1:^A}52| - {2:-- More --}^ | - ]]) - feed('q') - screen:expect([[ - ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - | - ]]) + local screen + + describe('more prompt', function() + before_each(function() + screen = Screen.new(75, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + [2] = {foreground = Screen.colors.Brown}, -- LineNr + [3] = {foreground = Screen.colors.Blue}, -- SpecialKey + }) + screen:attach() + command('set more') + end) + + -- oldtest: Test_message_more() + it('works', function() + command('call setline(1, range(1, 100))') + + feed(':%p#\n') + screen:expect([[ + {2: 1 }1 | + {2: 2 }2 | + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + {1:-- More --}^ | + ]]) + + feed('?') + screen:expect([[ + {2: 1 }1 | + {2: 2 }2 | + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + {1:-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit }^ | + ]]) + + -- Down a line with j, , or . + feed('j') + screen:expect([[ + {2: 2 }2 | + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + {2: 6 }6 | + {1:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + {2: 6 }6 | + {2: 7 }7 | + {1:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {2: 4 }4 | + {2: 5 }5 | + {2: 6 }6 | + {2: 7 }7 | + {2: 8 }8 | + {1:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {2: 5 }5 | + {2: 6 }6 | + {2: 7 }7 | + {2: 8 }8 | + {2: 9 }9 | + {1:-- More --}^ | + ]]) + + -- Down a screen with , f, or . + feed('f') + screen:expect([[ + {2: 10 }10 | + {2: 11 }11 | + {2: 12 }12 | + {2: 13 }13 | + {2: 14 }14 | + {1:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {2: 15 }15 | + {2: 16 }16 | + {2: 17 }17 | + {2: 18 }18 | + {2: 19 }19 | + {1:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {2: 20 }20 | + {2: 21 }21 | + {2: 22 }22 | + {2: 23 }23 | + {2: 24 }24 | + {1:-- More --}^ | + ]]) + + -- Down a page (half a screen) with d. + feed('d') + screen:expect([[ + {2: 23 }23 | + {2: 24 }24 | + {2: 25 }25 | + {2: 26 }26 | + {2: 27 }27 | + {1:-- More --}^ | + ]]) + + -- Down all the way with 'G'. + feed('G') + screen:expect([[ + {2: 96 }96 | + {2: 97 }97 | + {2: 98 }98 | + {2: 99 }99 | + {2:100 }100 | + {1:Press ENTER or type command to continue}^ | + ]]) + + -- Up a line k, or . + feed('k') + screen:expect([[ + {2: 95 }95 | + {2: 96 }96 | + {2: 97 }97 | + {2: 98 }98 | + {2: 99 }99 | + {1:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {2: 94 }94 | + {2: 95 }95 | + {2: 96 }96 | + {2: 97 }97 | + {2: 98 }98 | + {1:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {2: 93 }93 | + {2: 94 }94 | + {2: 95 }95 | + {2: 96 }96 | + {2: 97 }97 | + {1:-- More --}^ | + ]]) + + -- Up a screen with b or . + feed('b') + screen:expect([[ + {2: 88 }88 | + {2: 89 }89 | + {2: 90 }90 | + {2: 91 }91 | + {2: 92 }92 | + {1:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {2: 83 }83 | + {2: 84 }84 | + {2: 85 }85 | + {2: 86 }86 | + {2: 87 }87 | + {1:-- More --}^ | + ]]) + + -- Up a page (half a screen) with u. + feed('u') + screen:expect([[ + {2: 80 }80 | + {2: 81 }81 | + {2: 82 }82 | + {2: 83 }83 | + {2: 84 }84 | + {1:-- More --}^ | + ]]) + + -- Up all the way with 'g'. + feed('g') + screen:expect([[ + {2: 1 }1 | + {2: 2 }2 | + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + {1:-- More --}^ | + ]]) + + -- All the way down. Pressing f should do nothing but pressing + -- space should end the more prompt. + feed('G') + screen:expect([[ + {2: 96 }96 | + {2: 97 }97 | + {2: 98 }98 | + {2: 99 }99 | + {2:100 }100 | + {1:Press ENTER or type command to continue}^ | + ]]) + feed('f') + screen:expect_unchanged() + feed('') + screen:expect([[ + 96 | + 97 | + 98 | + 99 | + ^100 | + | + ]]) + + -- Pressing g< shows the previous command output. + feed('g') + screen:expect([[ + {2: 96 }96 | + {2: 97 }97 | + {2: 98 }98 | + {2: 99 }99 | + {2:100 }100 | + {1:Press ENTER or type command to continue}^ | + ]]) + + feed(':%p#\n') + screen:expect([[ + {2: 1 }1 | + {2: 2 }2 | + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + {1:-- More --}^ | + ]]) + + -- Stop command output with q, or CTRL-C. + feed('q') + screen:expect([[ + 96 | + 97 | + 98 | + 99 | + ^100 | + | + ]]) + end) + + -- oldtest: Test_quit_long_message() + it('with control characters can be quit vim-patch:8.2.1844', function() + screen:try_resize(40, 6) + feed([[:echom range(9999)->join("\x01")]]) + screen:expect([[ + 0{3:^A}1{3:^A}2{3:^A}3{3:^A}4{3:^A}5{3:^A}6{3:^A}7{3:^A}8{3:^A}9{3:^A}10{3:^A}11{3:^A}12| + {3:^A}13{3:^A}14{3:^A}15{3:^A}16{3:^A}17{3:^A}18{3:^A}19{3:^A}20{3:^A}21{3:^A}22| + {3:^A}23{3:^A}24{3:^A}25{3:^A}26{3:^A}27{3:^A}28{3:^A}29{3:^A}30{3:^A}31{3:^A}32| + {3:^A}33{3:^A}34{3:^A}35{3:^A}36{3:^A}37{3:^A}38{3:^A}39{3:^A}40{3:^A}41{3:^A}42| + {3:^A}43{3:^A}44{3:^A}45{3:^A}46{3:^A}47{3:^A}48{3:^A}49{3:^A}50{3:^A}51{3:^A}52| + {1:-- More --}^ | + ]]) + feed('q') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) end) + -- oldtest: Test_fileinfo_after_echo() it('fileinfo does not overwrite echo message vim-patch:8.2.4156', function() - local screen = Screen.new(40, 6) + screen = Screen.new(40, 6) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText }) screen:attach() exec([[ @@ -60,10 +311,10 @@ describe('messages', function() feed('0$') screen:expect([[ ^hi | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| 'b' written | ]]) os.remove('b.txt') -- cgit From bc73795a5858129a84d510f682c9dcb17aa1813a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 16 Jul 2022 21:14:54 +0800 Subject: vim-patch:8.2.0198: no tests for y/n prompt Problem: No tests for y/n prompt. Solution: Add tests. (Dominique Pelle, closes vim/vim#5564) https://github.com/vim/vim/commit/43c60eda2aa22ba3d7aaf418cfbdb75f1a008e67 --- src/nvim/testdir/test_messages.vim | 32 ++++++++++++++- test/functional/legacy/messages_spec.lua | 70 ++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index 6954b4bc91..fb6c9c1554 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -203,7 +203,37 @@ func Test_message_more() call term_sendkeys(buf, 'q') call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))}) - call term_sendkeys(buf, ':q!') + call term_sendkeys(buf, ":q!\n") + call StopVimInTerminal(buf) +endfunc + +func Test_ask_yesno() + if !CanRunVimInTerminal() + throw 'Skipped: cannot run vim in terminal' + endif + let buf = RunVimInTerminal('', {'rows': 6}) + call term_sendkeys(buf, ":call setline(1, range(1, 2))\n") + + call term_sendkeys(buf, ":2,1s/^/n/\n") + call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))}) + call term_sendkeys(buf, "n") + call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?n *1,1 *All$', term_getline(buf, 6))}) + call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))}) + + call term_sendkeys(buf, ":2,1s/^/Esc/\n") + call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?n *1,1 *All$', term_getline(buf, 6))}) + call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))}) + + call term_sendkeys(buf, ":2,1s/^/y/\n") + call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))}) + call term_sendkeys(buf, "y") + call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?y *2,1 *All$', term_getline(buf, 6))}) + call WaitForAssert({-> assert_equal('y1', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('y2', term_getline(buf, 2))}) + + call term_sendkeys(buf, ":q!\n") call StopVimInTerminal(buf) endfunc diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 9fd6090969..2b0e6941ef 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -287,6 +287,76 @@ describe('messages', function() end) end) + -- oldtest: Test_ask_yesno() + it('y/n prompt works', function() + screen = Screen.new(75, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + [2] = {bold = true, reverse = true}, -- MsgSeparator + }) + screen:attach() + command('set noincsearch nohlsearch inccommand=') + command('call setline(1, range(1, 2))') + + feed(':2,1s/^/n/\n') + screen:expect([[ + 1 | + 2 | + {0:~ }| + {0:~ }| + {0:~ }| + {1:Backwards range given, OK to swap (y/n)?}^ | + ]]) + feed('n') + screen:expect([[ + ^1 | + 2 | + {0:~ }| + {0:~ }| + {0:~ }| + {1:Backwards range given, OK to swap (y/n)?}n | + ]]) + + feed(':2,1s/^/Esc/\n') + screen:expect([[ + 1 | + 2 | + {0:~ }| + {0:~ }| + {0:~ }| + {1:Backwards range given, OK to swap (y/n)?}^ | + ]]) + feed('') + screen:expect([[ + ^1 | + 2 | + {0:~ }| + {0:~ }| + {0:~ }| + {1:Backwards range given, OK to swap (y/n)?}n | + ]]) + + feed(':2,1s/^/y/\n') + screen:expect([[ + 1 | + 2 | + {0:~ }| + {0:~ }| + {0:~ }| + {1:Backwards range given, OK to swap (y/n)?}^ | + ]]) + feed('y') + screen:expect([[ + y1 | + ^y2 | + {0:~ }| + {0:~ }| + {0:~ }| + {1:Backwards range given, OK to swap (y/n)?}y | + ]]) + end) + -- oldtest: Test_fileinfo_after_echo() it('fileinfo does not overwrite echo message vim-patch:8.2.4156', function() screen = Screen.new(40, 6) -- cgit From 780edfc0eb1293f5813d904ad61fc65bbbb41784 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 16 Jul 2022 21:39:05 +0800 Subject: vim-patch:8.2.2608: character input not fully tested Problem: Character input not fully tested. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#7963) https://github.com/vim/vim/commit/f4fcedc59d4cc5ae6b5270a933e8377030283c1c Cherry-pick related changes from patches 8.2.{0433,0866}. --- src/nvim/testdir/test_messages.vim | 21 +++++++++++++-------- src/nvim/testdir/test_registers.vim | 10 ++++++++++ src/nvim/testdir/test_undo.vim | 14 ++++++++++++++ test/functional/legacy/messages_spec.lua | 29 +++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 8 deletions(-) diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index fb6c9c1554..5670368936 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -114,9 +114,7 @@ endfunc " Test more-prompt (see :help more-prompt). func Test_message_more() - if !CanRunVimInTerminal() - throw 'Skipped: cannot run vim in terminal' - endif + CheckRunVimInTerminal let buf = RunVimInTerminal('', {'rows': 6}) call term_sendkeys(buf, ":call setline(1, range(1, 100))\n") @@ -203,14 +201,22 @@ func Test_message_more() call term_sendkeys(buf, 'q') call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))}) - call term_sendkeys(buf, ":q!\n") + " Execute a : command from the more prompt + call term_sendkeys(buf, ":%p#\n") + call term_wait(buf) + call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) + call term_sendkeys(buf, ":") + call term_wait(buf) + call WaitForAssert({-> assert_equal(':', term_getline(buf, 6))}) + call term_sendkeys(buf, "echo 'Hello'\n") + call term_wait(buf) + call WaitForAssert({-> assert_equal('Hello ', term_getline(buf, 5))}) + call StopVimInTerminal(buf) endfunc func Test_ask_yesno() - if !CanRunVimInTerminal() - throw 'Skipped: cannot run vim in terminal' - endif + CheckRunVimInTerminal let buf = RunVimInTerminal('', {'rows': 6}) call term_sendkeys(buf, ":call setline(1, range(1, 2))\n") @@ -233,7 +239,6 @@ func Test_ask_yesno() call WaitForAssert({-> assert_equal('y1', term_getline(buf, 1))}) call WaitForAssert({-> assert_equal('y2', term_getline(buf, 2))}) - call term_sendkeys(buf, ":q!\n") call StopVimInTerminal(buf) endfunc diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim index abe28b77cd..52e745438d 100644 --- a/src/nvim/testdir/test_registers.vim +++ b/src/nvim/testdir/test_registers.vim @@ -684,6 +684,16 @@ func Test_insert_small_delete() bwipe! endfunc +" Record in insert mode using CTRL-O +func Test_record_in_insert_mode() + new + let @r = '' + call setline(1, ['foo']) + call feedkeys("i\qrbaz\q", 'xt') + call assert_equal('baz', @r) + bwipe! +endfunc + func Test_record_in_select_mode() new call setline(1, 'text') diff --git a/src/nvim/testdir/test_undo.vim b/src/nvim/testdir/test_undo.vim index da8bf12318..efc39fb3f5 100644 --- a/src/nvim/testdir/test_undo.vim +++ b/src/nvim/testdir/test_undo.vim @@ -735,6 +735,20 @@ func Test_undofile_cryptmethod_blowfish2() set undofile& undolevels& cryptmethod& endfunc +" Test for redoing with incrementing numbered registers +func Test_redo_repeat_numbered_register() + new + for [i, v] in [[1, 'one'], [2, 'two'], [3, 'three'], + \ [4, 'four'], [5, 'five'], [6, 'six'], + \ [7, 'seven'], [8, 'eight'], [9, 'nine']] + exe 'let @' .. i .. '="' .. v .. '\n"' + endfor + call feedkeys('"1p.........', 'xt') + call assert_equal(['', 'one', 'two', 'three', 'four', 'five', 'six', + \ 'seven', 'eight', 'nine', 'nine'], getline(1, '$')) + bwipe! +endfunc + func Test_undo_mark() new " The undo is applied to the only line. diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 2b0e6941ef..b296ac909d 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -261,6 +261,35 @@ describe('messages', function() ^100 | | ]]) + + -- Execute a : command from the more prompt + feed(':%p#\n') + screen:expect([[ + {2: 1 }1 | + {2: 2 }2 | + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + {1:-- More --}^ | + ]]) + feed(':') + screen:expect([[ + {2: 1 }1 | + {2: 2 }2 | + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + :^ | + ]]) + feed("echo 'Hello'\n") + screen:expect([[ + {2: 2 }2 | + {2: 3 }3 | + {2: 4 }4 | + {2: 5 }5 | + Hello | + {1:Press ENTER or type command to continue}^ | + ]]) end) -- oldtest: Test_quit_long_message() -- cgit From 0cfd4fa8f3dc2241de5f69d5c52510542dfc927c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 16 Jul 2022 21:56:47 +0800 Subject: vim-patch:8.2.2643: various code not covered by tests Problem: Various code not covered by tests. Solution: Add a few more test. (Yegappan Lakshmanan, closes vim/vim#7995) https://github.com/vim/vim/commit/1f448d906b3c516e5864dc5bae3ddbf3664ee649 Cherry-pick some test_edit.vim changes from patches 8.2.{1022,1432}. Reorder test_undo.vim to match upstream. --- src/nvim/testdir/test_edit.vim | 39 ++++++++++- src/nvim/testdir/test_mapping.vim | 10 +++ src/nvim/testdir/test_termcodes.vim | 34 ++++++++++ src/nvim/testdir/test_undo.vim | 127 ++++++++++++++++++----------------- test/functional/legacy/edit_spec.lua | 26 +++++++ 5 files changed, 173 insertions(+), 63 deletions(-) create mode 100644 test/functional/legacy/edit_spec.lua diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 65194f49dd..69a34a1c51 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -420,16 +420,49 @@ func Test_edit_13() call assert_equal("", getline(2)) call assert_equal(" baz", getline(3)) set autoindent& + + " pressing to erase line should keep the indent with 'autoindent' + set backspace=2 autoindent + %d + exe "normal i\tone\three\two" + call assert_equal(["\tone", "\ttwo"], getline(1, '$')) + set backspace& autoindent& + bwipe! endfunc +" Test for autoindent removing indent when insert mode is stopped. Some parts +" of the code is exercised only when interactive mode is used. So use Vim in a +" terminal. +func Test_autoindent_remove_indent() + CheckRunVimInTerminal + let buf = RunVimInTerminal('-N Xfile', {'rows': 6, 'cols' : 20}) + call TermWait(buf) + call term_sendkeys(buf, ":set autoindent\n") + " leaving insert mode in a new line with indent added by autoindent, should + " remove the indent. + call term_sendkeys(buf, "i\foo\\") + " Need to delay for sometime, otherwise the code in getchar.c will not be + " exercised. + call TermWait(buf, 50) + " when a line is wrapped and the cursor is at the start of the second line, + " leaving insert mode, should move the cursor back to the first line. + call term_sendkeys(buf, "o" .. repeat('x', 20) .. "\") + " Need to delay for sometime, otherwise the code in getchar.c will not be + " exercised. + call TermWait(buf, 50) + call term_sendkeys(buf, ":w\n") + call TermWait(buf) + call StopVimInTerminal(buf) + call assert_equal(["\tfoo", '', repeat('x', 20)], readfile('Xfile')) + call delete('Xfile') +endfunc + func Test_edit_CR() " Test for in insert mode " basically only in quickfix mode ist tested, the rest " has been taken care of by other tests - if !has("quickfix") - return - endif + CheckFeature quickfix botright new call writefile(range(1, 10), 'Xqflist.txt') call setqflist([{'filename': 'Xqflist.txt', 'lnum': 2}]) diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index a34a950526..e1d0b9a9ba 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -956,6 +956,16 @@ func Test_map_cmdkey_redo() ounmap i- endfunc +" Test for using