Skip to content

Commit 6e72cd0

Browse files
committed
patch 8.0.1714: term_setsize() does not give an error in a normal buffer
Problem: Term_setsize() does not give an error in a normal buffer. Solution: Add an error message.
1 parent b3623a3 commit 6e72cd0

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/terminal.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4629,7 +4629,12 @@ f_term_setsize(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
46294629
term_T *term;
46304630
varnumber_T rows, cols;
46314631

4632-
if (buf == NULL || buf->b_term->tl_vterm == NULL)
4632+
if (buf == NULL)
4633+
{
4634+
EMSG(_("E955: Not a terminal buffer"));
4635+
return;
4636+
}
4637+
if (buf->b_term->tl_vterm == NULL)
46334638
return;
46344639
term = buf->b_term;
46354640
rows = get_tv_number(&argvars[1]);

src/testdir/test_terminal.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,27 @@ func Test_terminal_scroll()
271271
call delete('Xtext')
272272
endfunc
273273

274+
func Test_terminal_scrollback()
275+
let buf = Run_shell_in_terminal({})
276+
set terminalscroll=100
277+
call writefile(range(150), 'Xtext')
278+
if has('win32')
279+
call term_sendkeys(buf, "type Xtext\<CR>")
280+
else
281+
call term_sendkeys(buf, "cat Xtext\<CR>")
282+
endif
283+
let rows = term_getsize(buf)[0]
284+
call WaitFor({-> term_getline(buf, rows - 1) =~ '149'})
285+
let lines = line('$')
286+
call assert_true(lines <= 100)
287+
call assert_true(lines > 90)
288+
289+
call Stop_shell_in_terminal(buf)
290+
call term_wait(buf)
291+
exe buf . 'bwipe'
292+
set terminalscroll&
293+
endfunc
294+
274295
func Test_terminal_size()
275296
let cmd = Get_cat_123_cmd()
276297

@@ -298,6 +319,7 @@ func Test_terminal_size()
298319
call assert_equal([7, 30], term_getsize(''))
299320

300321
bwipe!
322+
call assert_fails("call term_setsize('', 7, 30)", "E955:")
301323

302324
call term_start(cmd, {'term_rows': 6, 'term_cols': 36})
303325
let size = term_getsize('')

src/version.c

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

763763
static int included_patches[] =
764764
{ /* Add new patch number below this line */
765+
/**/
766+
1714,
765767
/**/
766768
1713,
767769
/**/

0 commit comments

Comments
 (0)