Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brammool committed Apr 14, 2018
1 parent b3623a3 commit 6e72cd0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/terminal.c
Expand Up @@ -4629,7 +4629,12 @@ f_term_setsize(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
term_T *term;
varnumber_T rows, cols;

if (buf == NULL || buf->b_term->tl_vterm == NULL)
if (buf == NULL)
{
EMSG(_("E955: Not a terminal buffer"));
return;
}
if (buf->b_term->tl_vterm == NULL)
return;
term = buf->b_term;
rows = get_tv_number(&argvars[1]);
Expand Down
22 changes: 22 additions & 0 deletions src/testdir/test_terminal.vim
Expand Up @@ -271,6 +271,27 @@ func Test_terminal_scroll()
call delete('Xtext')
endfunc

func Test_terminal_scrollback()
let buf = Run_shell_in_terminal({})
set terminalscroll=100
call writefile(range(150), 'Xtext')
if has('win32')
call term_sendkeys(buf, "type Xtext\<CR>")
else
call term_sendkeys(buf, "cat Xtext\<CR>")
endif
let rows = term_getsize(buf)[0]
call WaitFor({-> term_getline(buf, rows - 1) =~ '149'})
let lines = line('$')
call assert_true(lines <= 100)
call assert_true(lines > 90)

call Stop_shell_in_terminal(buf)
call term_wait(buf)
exe buf . 'bwipe'
set terminalscroll&
endfunc

func Test_terminal_size()
let cmd = Get_cat_123_cmd()

Expand Down Expand Up @@ -298,6 +319,7 @@ func Test_terminal_size()
call assert_equal([7, 30], term_getsize(''))

bwipe!
call assert_fails("call term_setsize('', 7, 30)", "E955:")

call term_start(cmd, {'term_rows': 6, 'term_cols': 36})
let size = term_getsize('')
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -762,6 +762,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1714,
/**/
1713,
/**/
Expand Down

0 comments on commit 6e72cd0

Please sign in to comment.