# HG changeset patch # User Bram Moolenaar # Date 1590147903 -7200 # Node ID 357dea6b9fdeff46b3ad6e6d8d204a039f418f4e # Parent 6dd44f4380bdf11fca4a81439f65ee8eb68b3f6a patch 8.2.0808: not enough testing for the terminal window Commit: https://github.com/vim/vim/commit/98f1671cc0ab0ad6139cb9c6ce5262e7f646bc0a Author: Bram Moolenaar Date: Fri May 22 13:34:01 2020 +0200 patch 8.2.0808: not enough testing for the terminal window Problem: Not enough testing for the terminal window. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6069) Fix memory leak. diff --git a/src/terminal.c b/src/terminal.c --- a/src/terminal.c +++ b/src/terminal.c @@ -3047,7 +3047,7 @@ handle_settermprop( #endif else { - term->tl_title = vim_strsave(strval); + term->tl_title = strval; strval = NULL; } VIM_CLEAR(term->tl_status_text); diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -850,8 +850,7 @@ func Test_gui_run_cmd_in_terminal() " assume all the other systems have a cat command let cmd = 'cat' endif - let cmd = ':silent !' . cmd . " test_gui.vim\\" - call feedkeys(cmd, 'xt') + exe "silent !" . cmd . " test_gui.vim" " TODO: how to check that the command ran in a separate terminal? " Maybe check for $TERM (dumb vs xterm) in the spawned shell? let &guioptions = save_guioptions diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -1220,6 +1220,7 @@ func Test_terminal_dumpwrite_errors() call delete('Xtest.dump') call assert_fails("call term_dumpwrite(buf, '')", 'E482:') call assert_fails("call term_dumpwrite(buf, test_null_string())", 'E482:') + call test_garbagecollect_now() call StopVimInTerminal(buf) call term_wait(buf) call assert_fails("call term_dumpwrite(buf, 'Xtest.dump')", 'E958:') @@ -1305,6 +1306,16 @@ func Test_terminal_dumpdiff_swap() call assert_match('three four five', getline(3)) call assert_match('Undo', getline(45)) quit + + " Diff two terminal dump files with different number of rows + " Swap the diffs + call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_winline_rnu.dump') + call assert_match('Test_popup_command_01.dump', getline(21)) + call assert_match('Test_winline_rnu.dump', getline(42)) + normal s + call assert_match('Test_winline_rnu.dump', getline(6)) + call assert_match('Test_popup_command_01.dump', getline(27)) + quit endfunc func Test_terminal_dumpdiff_options() @@ -1619,6 +1630,7 @@ func Test_terminal_ansicolors_default() call assert_equal(colors, term_getansicolors(buf)) call StopShellInTerminal(buf) call TermWait(buf) + call assert_equal([], term_getansicolors(buf)) exe buf . 'bwipe' endfunc @@ -1673,9 +1685,11 @@ func Test_terminal_ansicolors_func() let colors[4] = 'Invalid' call assert_fails('call term_setansicolors(buf, colors)', 'E474:') + call assert_fails('call term_setansicolors(buf, {})', 'E714:') call StopShellInTerminal(buf) call TermWait(buf) + call assert_equal(0, term_setansicolors(buf, [])) exe buf . 'bwipe' endfunc @@ -2029,7 +2043,7 @@ func Test_terminal_switch_mode() call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))}) call feedkeys("A", 'xt') call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))}) - call feedkeys("\N", 'xt') + call feedkeys("\\", 'xt') call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))}) call feedkeys("I", 'xt') call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))}) @@ -2066,6 +2080,7 @@ func Test_terminal_normal_mode() call term_sendkeys(buf, ":set culopt=line\r") call VerifyScreenDump(buf, 'Test_terminal_normal_3', {}) + call assert_fails('call term_sendkeys(buf, [])', 'E730:') call term_sendkeys(buf, "a:q!\:q\:q\") call StopVimInTerminal(buf) call delete('XtermNormal') @@ -2178,17 +2193,18 @@ func Test_term_getcursor() call StopShellInTerminal(buf) endfunc +" Test for term_gettitle() func Test_term_gettitle() " term_gettitle() returns an empty string for a non-terminal buffer " and for a non-existing buffer. call assert_equal('', bufnr('%')->term_gettitle()) call assert_equal('', term_gettitle(bufnr('$') + 1)) - if !has('title') || &title == 0 || empty(&t_ts) + if !has('title') || empty(&t_ts) throw "Skipped: can't get/set title" endif - let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile']) + let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', '-c', 'set title']) if has('autoservername') call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d\+$', term_gettitle(term)) }) call term_sendkeys(term, ":e Xfoo\r") @@ -2692,15 +2708,6 @@ func Test_term_keycode_translation() call assert_equal(output[i], term_getline(buf, 1)) endfor - "call term_sendkeys(buf, "\\\\\\\\\\") - "call term_sendkeys(buf, "\\\") - "call term_sendkeys(buf, "\\\") - "call term_sendkeys(buf, "\") - "call term_sendkeys(buf, "\\\\") - "call term_sendkeys(buf, "\") - - "call term_sendkeys(buf, ":write Xkeycodes\") - let keypad_keys = ["\", "\", "\", "\", "\", "\", \ "\", "\", "\", "\", "\", "\", \ "\", "\", "\"] @@ -2733,7 +2740,6 @@ func Test_term_mouse() let save_term = &term let save_ttymouse = &ttymouse let save_clipboard = &clipboard - call test_override('no_query_mouse', 1) set mouse=a term=xterm ttymouse=sgr mousetime=200 clipboard= let lines =<< trim END @@ -2743,6 +2749,8 @@ func Test_term_mouse() END call writefile(lines, 'Xtest_mouse') + " Create a terminal window running Vim for the test with mouse enabled + let prev_win = win_getid() let buf = RunVimInTerminal('Xtest_mouse -n', {}) call term_sendkeys(buf, ":set nocompatible\") call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\") @@ -2751,6 +2759,12 @@ func Test_term_mouse() call term_wait(buf) redraw! + " Use the mouse to enter the terminal window + call win_gotoid(prev_win) + call feedkeys(MouseLeftClickCode(1, 1), 'x') + call feedkeys(MouseLeftReleaseCode(1, 1), 'x') + call assert_equal(1, getwininfo(win_getid())[0].terminal) + " Test for click/release call test_setmouse(2, 5) call feedkeys("\\", 'xt') @@ -2833,7 +2847,6 @@ func Test_term_mouse() let &ttymouse = save_ttymouse let &clipboard = save_clipboard set mousetime& - call test_override('no_query_mouse', 0) call delete('Xtest_mouse') call delete('Xbuf') endfunc @@ -2848,7 +2861,6 @@ func Test_term_modeless_selection() let save_mouse = &mouse let save_term = &term let save_ttymouse = &ttymouse - call test_override('no_query_mouse', 1) set mouse=a term=xterm ttymouse=sgr mousetime=200 set clipboard=autoselectml @@ -2859,12 +2871,21 @@ func Test_term_modeless_selection() END call writefile(lines, 'Xtest_modeless') + " Create a terminal window running Vim for the test with mouse disabled + let prev_win = win_getid() let buf = RunVimInTerminal('Xtest_modeless -n', {}) call term_sendkeys(buf, ":set nocompatible\") call term_sendkeys(buf, ":set mouse=\") call term_wait(buf) redraw! + " Use the mouse to enter the terminal window + call win_gotoid(prev_win) + call feedkeys(MouseLeftClickCode(1, 1), 'x') + call feedkeys(MouseLeftReleaseCode(1, 1), 'x') + call term_wait(buf) + call assert_equal(1, getwininfo(win_getid())[0].terminal) + " Test for copying a modeless selection to clipboard let @* = 'clean' " communicating with X server may take a little time @@ -2881,8 +2902,8 @@ func Test_term_modeless_selection() let &term = save_term let &ttymouse = save_ttymouse set mousetime& clipboard& - call test_override('no_query_mouse', 0) call delete('Xtest_modeless') + new | only! endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 808, +/**/ 807, /**/ 806,