]> granicus.if.org Git - vim/commitdiff
patch 8.0.1848: 'termwinscroll' does not work properly v8.0.1848
authorBram Moolenaar <Bram@vim.org>
Tue, 15 May 2018 21:53:26 +0000 (23:53 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 15 May 2018 21:53:26 +0000 (23:53 +0200)
Problem:    'termwinscroll' does not work properly. (Dominique Pelle)
Solution:   Subtract removed scrollback from the scrollback count.  Add a test
            for 'termwinscroll'. (closes #2909)

src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index 282f98102658f3ada5d2f0047e96080bb43d71c3..849d926fe7ebf834401e115f39fca50e3603c51e 100644 (file)
@@ -46,6 +46,7 @@
  * - Win32: Redirecting output works but includes escape sequences.
  * - Win32: Make terminal used for :!cmd in the GUI work better.  Allow for
  *   redirection.
+ * - terminal API: Add more functionality? (Ozaki Kiichi 2018 May 13, #2907)
  * - When the job only outputs lines, we could handle resizing the terminal
  *   better: store lines separated by line breaks, instead of screen lines,
  *   then when the window is resized redraw those lines.
@@ -2727,6 +2728,7 @@ handle_pushline(int cols, const VTermScreenCell *cells, void *user)
        mch_memmove(term->tl_scrollback.ga_data,
            (sb_line_T *)term->tl_scrollback.ga_data + todo,
            sizeof(sb_line_T) * term->tl_scrollback.ga_len);
+       term->tl_scrollback_scrolled -= todo;
     }
 
     if (ga_grow(&term->tl_scrollback, 1) == OK)
index e9b69533d66bb14cdb1be5021ee42c234a0c52a4..c4e49b730f3a43b2a43054009c828021436ff846 100644 (file)
@@ -1507,3 +1507,30 @@ func Test_terminal_out_err()
   call delete('Xechoerrout.sh')
   call delete(outfile)
 endfunc
+
+func Test_terminwinscroll()
+  if !has('unix')
+    return
+  endif
+
+  " Let the terminal output more than 'termwinscroll' lines, some at the start
+  " will be dropped.
+  exe 'set termwinscroll=' . &lines
+  let buf = term_start('/bin/sh')
+  for i in range(1, &lines)
+    call feedkeys("echo " . i . "\<CR>", 'xt')
+    call WaitForAssert({-> assert_match(string(i), term_getline(buf, term_getcursor(buf)[0] - 1))})
+  endfor
+  " Go to Terminal-Normal mode to update the buffer.
+  call feedkeys("\<C-W>N", 'xt')
+  call assert_inrange(&lines, &lines * 110 / 100 + winheight(0), line('$'))
+
+  " Every "echo nr" must only appear once
+  let lines = getline(1, line('$'))
+  for i in range(&lines - len(lines) / 2 + 2, &lines)
+    let filtered = filter(copy(lines), {idx, val -> val =~ 'echo ' . i . '\>'})
+    call assert_equal(1, len(filtered), 'for "echo ' . i . '"')
+  endfor
+
+  exe buf . 'bwipe!'
+endfunc
index fffdbf6b8034fafabfc41f6fb4391f508183d1c4..9697d8eaf6a8696ff33328318e10aafe93b54247 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1848,
 /**/
     1847,
 /**/