Skip to content

Commit 4d6cd29

Browse files
committed
patch 8.0.1848: 'termwinscroll' does not work properly
Problem: 'termwinscroll' does not work properly. (Dominique Pelle) Solution: Subtract removed scrollback from the scrollback count. Add a test for 'termwinscroll'. (closes #2909)
1 parent 825ccf4 commit 4d6cd29

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/terminal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* - Win32: Redirecting output works but includes escape sequences.
4747
* - Win32: Make terminal used for :!cmd in the GUI work better. Allow for
4848
* redirection.
49+
* - terminal API: Add more functionality? (Ozaki Kiichi 2018 May 13, #2907)
4950
* - When the job only outputs lines, we could handle resizing the terminal
5051
* better: store lines separated by line breaks, instead of screen lines,
5152
* then when the window is resized redraw those lines.
@@ -2727,6 +2728,7 @@ handle_pushline(int cols, const VTermScreenCell *cells, void *user)
27272728
mch_memmove(term->tl_scrollback.ga_data,
27282729
(sb_line_T *)term->tl_scrollback.ga_data + todo,
27292730
sizeof(sb_line_T) * term->tl_scrollback.ga_len);
2731+
term->tl_scrollback_scrolled -= todo;
27302732
}
27312733

27322734
if (ga_grow(&term->tl_scrollback, 1) == OK)

src/testdir/test_terminal.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,3 +1507,30 @@ func Test_terminal_out_err()
15071507
call delete('Xechoerrout.sh')
15081508
call delete(outfile)
15091509
endfunc
1510+
1511+
func Test_terminwinscroll()
1512+
if !has('unix')
1513+
return
1514+
endif
1515+
1516+
" Let the terminal output more than 'termwinscroll' lines, some at the start
1517+
" will be dropped.
1518+
exe 'set termwinscroll=' . &lines
1519+
let buf = term_start('/bin/sh')
1520+
for i in range(1, &lines)
1521+
call feedkeys("echo " . i . "\<CR>", 'xt')
1522+
call WaitForAssert({-> assert_match(string(i), term_getline(buf, term_getcursor(buf)[0] - 1))})
1523+
endfor
1524+
" Go to Terminal-Normal mode to update the buffer.
1525+
call feedkeys("\<C-W>N", 'xt')
1526+
call assert_inrange(&lines, &lines * 110 / 100 + winheight(0), line('$'))
1527+
1528+
" Every "echo nr" must only appear once
1529+
let lines = getline(1, line('$'))
1530+
for i in range(&lines - len(lines) / 2 + 2, &lines)
1531+
let filtered = filter(copy(lines), {idx, val -> val =~ 'echo ' . i . '\>'})
1532+
call assert_equal(1, len(filtered), 'for "echo ' . i . '"')
1533+
endfor
1534+
1535+
exe buf . 'bwipe!'
1536+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1848,
764766
/**/
765767
1847,
766768
/**/

0 commit comments

Comments
 (0)