patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Problem: Term_start() options for size are overruled by 'termwinsize'.
(Sergey Vlasov)
Solution: Set 'termwinsize' to the specified size.
diff --git a/src/testdir/term_util.vim b/src/testdir/term_util.vim
index 17f9752..4a5e649 100644
--- a/src/testdir/term_util.vim
+++ b/src/testdir/term_util.vim
@@ -73,7 +73,8 @@
set t_Co=256 background=light
hi Normal ctermfg=NONE ctermbg=NONE
- " Make the window 20 lines high and 75 columns, unless told otherwise.
+ " Make the window 20 lines high and 75 columns, unless told otherwise or
+ " 'termwinsize' is set.
let rows = get(a:options, 'rows', 20)
let cols = get(a:options, 'cols', 75)
let statusoff = get(a:options, 'statusoff', 1)
@@ -86,11 +87,12 @@
let cmd = GetVimCommandCleanTerm() .. reset_u7 .. a:arguments
- let options = {
- \ 'curwin': 1,
- \ 'term_rows': rows,
- \ 'term_cols': cols,
- \ }
+ let options = #{curwin: 1}
+ if &termwinsize == ''
+ let options.term_rows = rows
+ let options.term_cols = cols
+ endif
+
" Accept other options whose name starts with 'term_'.
call extend(options, filter(copy(a:options), 'v:key =~# "^term_"'))
diff --git a/src/testdir/test_terminal2.vim b/src/testdir/test_terminal2.vim
index 93ace42..f9f221b 100644
--- a/src/testdir/test_terminal2.vim
+++ b/src/testdir/test_terminal2.vim
@@ -109,6 +109,27 @@
set termwinsize=
endfunc
+func Test_terminal_termwinsize_overruled()
+ let cmd = GetDummyCmd()
+ set termwinsize=5x43
+ let buf = term_start(cmd, #{term_rows: 7, term_cols: 50})
+ call TermWait(buf)
+ call assert_equal([7, 50], term_getsize(buf))
+ exe "bwipe! " .. buf
+
+ let buf = term_start(cmd, #{term_cols: 50})
+ call TermWait(buf)
+ call assert_equal([5, 50], term_getsize(buf))
+ exe "bwipe! " .. buf
+
+ let buf = term_start(cmd, #{term_rows: 7})
+ call TermWait(buf)
+ call assert_equal([7, 43], term_getsize(buf))
+ exe "bwipe! " .. buf
+
+ set termwinsize=
+endfunc
+
func Test_terminal_termwinkey()
" make three tabpages, terminal in the middle
0tabnew
@@ -397,13 +418,17 @@
call delete('Xfile')
endfunc
-func Test_terminal_no_job()
+func GetDummyCmd()
if has('win32')
- let cmd = 'cmd /c ""'
+ return 'cmd /c ""'
else
CheckExecutable false
- let cmd = 'false'
+ return 'false'
endif
+endfunc
+
+func Test_terminal_no_job()
+ let cmd = GetDummyCmd()
let term = term_start(cmd, {'term_finish': 'close'})
call WaitForAssert({-> assert_equal(v:null, term_getjob(term)) })
endfunc