aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/testdir/test_messages.vim32
-rw-r--r--test/functional/legacy/messages_spec.lua70
2 files changed, 101 insertions, 1 deletions
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, "\<Esc>")
+ 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('<Esc>')
+ 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)