changeset 18983:54baf548bff9 v8.2.0052

patch 8.2.0052: more-prompt not properly tested Commit: https://github.com/vim/vim/commit/c6d539b67181ad573452e919e58ecbfa362f4c49 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 28 17:10:46 2019 +0100 patch 8.2.0052: more-prompt not properly tested Problem: More-prompt not properly tested. Solution: Add a test case. (Dominique Pelle, closes https://github.com/vim/vim/issues/5404)
author Bram Moolenaar <Bram@vim.org>
date Sat, 28 Dec 2019 17:15:04 +0100
parents 26a583bf16df
children 6642c88759de
files src/testdir/test_messages.vim src/version.c
diffstat 2 files changed, 98 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -1,6 +1,7 @@
 " Tests for :messages, :echomsg, :echoerr
 
 source shared.vim
+source term_util.vim
 
 function Test_messages()
   let oldmore = &more
@@ -172,3 +173,98 @@ 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, <CR>, <NL> or <Down>.
+  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, "\<NL>")
+  call WaitForAssert({-> assert_equal('  7 7', term_getline(buf, 5))})
+  call term_sendkeys(buf, "\<CR>")
+  call WaitForAssert({-> assert_equal('  8 8', term_getline(buf, 5))})
+  call term_sendkeys(buf, "\<Down>")
+  call WaitForAssert({-> assert_equal('  9 9', term_getline(buf, 5))})
+
+  " Down a screen with <Space>, f, or <PageDown>.
+  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, "\<PageDown>")
+  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, <BS> or <Up>.
+  call term_sendkeys(buf, 'k')
+  call WaitForAssert({-> assert_equal(' 99 99', term_getline(buf, 5))})
+  call term_sendkeys(buf, "\<BS>")
+  call WaitForAssert({-> assert_equal(' 98 98', term_getline(buf, 5))})
+  call term_sendkeys(buf, "\<Up>")
+  call WaitForAssert({-> assert_equal(' 97 97', term_getline(buf, 5))})
+
+  " Up a screen with b or <PageUp>.
+  call term_sendkeys(buf, 'b')
+  call WaitForAssert({-> assert_equal(' 92 92', term_getline(buf, 5))})
+  call term_sendkeys(buf, "\<PageUp>")
+  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, <Esc> 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
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    52,
+/**/
     51,
 /**/
     50,