To: vim_dev@googlegroups.com Subject: Patch 8.1.2066 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2066 Problem: No tests for state(). Solution: Add tests. Clean up some feature checks. Make "a" flag work. Files: src/testdir/test_functions.vim, src/testdir/test_terminal.vim, src/misc1.c *** ../vim-8.1.2065/src/testdir/test_functions.vim 2019-09-15 21:12:18.528950026 +0200 --- src/testdir/test_functions.vim 2019-09-22 21:26:04.468443194 +0200 *************** *** 1,6 **** --- 1,7 ---- " Tests for various functions. source shared.vim source check.vim + source term_util.vim " Must be done first, since the alternate buffer must be unset. func Test_00_bufexists() *************** *** 1659,1661 **** --- 1660,1721 ---- call assert_equal(0, bufexists('someName')) call delete('XotherName') endfunc + + func Test_state() + CheckRunVimInTerminal + + let lines =<< trim END + call setline(1, ['one', 'two', 'three']) + map ;; gg + func RunTimer() + call timer_start(10, {id -> execute('let g:state = state()') .. execute('let g:mode = mode()')}) + endfunc + au Filetype foobar let g:state = state()|let g:mode = mode() + END + call writefile(lines, 'XState') + let buf = RunVimInTerminal('-S XState', #{rows: 6}) + + " Using a ":" command Vim is busy, thus "S" is returned + call term_sendkeys(buf, ":echo 'state: ' .. state() .. '; mode: ' .. mode()\") + call WaitForAssert({-> assert_match('state: S; mode: n', term_getline(buf, 6))}, 1000) + call term_sendkeys(buf, ":\") + + " Using a timer callback + call term_sendkeys(buf, ":call RunTimer()\") + call term_wait(buf, 50) + let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\" + call term_sendkeys(buf, getstate) + call WaitForAssert({-> assert_match('state: c; mode: n', term_getline(buf, 6))}, 1000) + + " Halfway a mapping + call term_sendkeys(buf, ":call RunTimer()\;") + call term_wait(buf, 50) + call term_sendkeys(buf, ";") + call term_sendkeys(buf, getstate) + call WaitForAssert({-> assert_match('state: mSc; mode: n', term_getline(buf, 6))}, 1000) + + " Insert mode completion + call term_sendkeys(buf, ":call RunTimer()\Got\") + call term_wait(buf, 50) + call term_sendkeys(buf, "\") + call term_sendkeys(buf, getstate) + call WaitForAssert({-> assert_match('state: aSc; mode: i', term_getline(buf, 6))}, 1000) + + " Autocommand executing + call term_sendkeys(buf, ":set filetype=foobar\") + call term_wait(buf, 50) + call term_sendkeys(buf, getstate) + call WaitForAssert({-> assert_match('state: xS; mode: n', term_getline(buf, 6))}, 1000) + + " Todo: "w" - waiting for ch_evalexpr() + + " messages scrolled + call term_sendkeys(buf, ":call RunTimer()\:echo \"one\\ntwo\\nthree\"\") + call term_wait(buf, 50) + call term_sendkeys(buf, "\") + call term_sendkeys(buf, getstate) + call WaitForAssert({-> assert_match('state: Scs; mode: r', term_getline(buf, 6))}, 1000) + + call StopVimInTerminal(buf) + call delete('XState') + endfunc *** ../vim-8.1.2065/src/testdir/test_terminal.vim 2019-09-21 22:56:59.484287781 +0200 --- src/testdir/test_terminal.vim 2019-09-22 20:30:54.330620555 +0200 *************** *** 1033,1041 **** " Run Vim in a terminal, then start a terminal in that Vim without a kill " argument, check that :confirm qall works. func Test_terminal_qall_prompt() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let buf = RunVimInTerminal('', {}) " Open a terminal window and wait for the prompt to appear --- 1033,1039 ---- " Run Vim in a terminal, then start a terminal in that Vim without a kill " argument, check that :confirm qall works. func Test_terminal_qall_prompt() ! CheckRunVimInTerminal let buf = RunVimInTerminal('', {}) " Open a terminal window and wait for the prompt to appear *************** *** 1094,1102 **** endfunc func Test_terminal_dumpwrite_composing() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let save_enc = &encoding set encoding=utf-8 call assert_equal(1, winnr('$')) --- 1092,1098 ---- endfunc func Test_terminal_dumpwrite_composing() ! CheckRunVimInTerminal let save_enc = &encoding set encoding=utf-8 call assert_equal(1, winnr('$')) *************** *** 1219,1227 **** endfunc func Test_terminal_api_drop_newwin() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let buf = Api_drop_common('') call assert_equal(0, &bin) call assert_equal('', &fenc) --- 1215,1221 ---- endfunc func Test_terminal_api_drop_newwin() ! CheckRunVimInTerminal let buf = Api_drop_common('') call assert_equal(0, &bin) call assert_equal('', &fenc) *************** *** 1232,1240 **** endfunc func Test_terminal_api_drop_newwin_bin() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let buf = Api_drop_common(',{"bin":1}') call assert_equal(1, &bin) --- 1226,1232 ---- endfunc func Test_terminal_api_drop_newwin_bin() ! CheckRunVimInTerminal let buf = Api_drop_common(',{"bin":1}') call assert_equal(1, &bin) *************** *** 1244,1252 **** endfunc func Test_terminal_api_drop_newwin_binary() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let buf = Api_drop_common(',{"binary":1}') call assert_equal(1, &bin) --- 1236,1242 ---- endfunc func Test_terminal_api_drop_newwin_binary() ! CheckRunVimInTerminal let buf = Api_drop_common(',{"binary":1}') call assert_equal(1, &bin) *************** *** 1256,1264 **** endfunc func Test_terminal_api_drop_newwin_nobin() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif set binary let buf = Api_drop_common(',{"nobin":1}') call assert_equal(0, &bin) --- 1246,1252 ---- endfunc func Test_terminal_api_drop_newwin_nobin() ! CheckRunVimInTerminal set binary let buf = Api_drop_common(',{"nobin":1}') call assert_equal(0, &bin) *************** *** 1270,1278 **** endfunc func Test_terminal_api_drop_newwin_nobinary() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif set binary let buf = Api_drop_common(',{"nobinary":1}') call assert_equal(0, &bin) --- 1258,1264 ---- endfunc func Test_terminal_api_drop_newwin_nobinary() ! CheckRunVimInTerminal set binary let buf = Api_drop_common(',{"nobinary":1}') call assert_equal(0, &bin) *************** *** 1284,1292 **** endfunc func Test_terminal_api_drop_newwin_ff() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let buf = Api_drop_common(',{"ff":"dos"}') call assert_equal("dos", &ff) --- 1270,1276 ---- endfunc func Test_terminal_api_drop_newwin_ff() ! CheckRunVimInTerminal let buf = Api_drop_common(',{"ff":"dos"}') call assert_equal("dos", &ff) *************** *** 1296,1304 **** endfunc func Test_terminal_api_drop_newwin_fileformat() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let buf = Api_drop_common(',{"fileformat":"dos"}') call assert_equal("dos", &ff) --- 1280,1286 ---- endfunc func Test_terminal_api_drop_newwin_fileformat() ! CheckRunVimInTerminal let buf = Api_drop_common(',{"fileformat":"dos"}') call assert_equal("dos", &ff) *************** *** 1308,1316 **** endfunc func Test_terminal_api_drop_newwin_enc() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let buf = Api_drop_common(',{"enc":"utf-16"}') call assert_equal("utf-16", &fenc) --- 1290,1296 ---- endfunc func Test_terminal_api_drop_newwin_enc() ! CheckRunVimInTerminal let buf = Api_drop_common(',{"enc":"utf-16"}') call assert_equal("utf-16", &fenc) *************** *** 1320,1328 **** endfunc func Test_terminal_api_drop_newwin_encoding() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let buf = Api_drop_common(',{"encoding":"utf-16"}') call assert_equal("utf-16", &fenc) --- 1300,1306 ---- endfunc func Test_terminal_api_drop_newwin_encoding() ! CheckRunVimInTerminal let buf = Api_drop_common(',{"encoding":"utf-16"}') call assert_equal("utf-16", &fenc) *************** *** 1332,1340 **** endfunc func Test_terminal_api_drop_oldwin() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif let firstwinid = win_getid() split Xtextfile let textfile_winid = win_getid() --- 1310,1316 ---- endfunc func Test_terminal_api_drop_oldwin() ! CheckRunVimInTerminal let firstwinid = win_getid() split Xtextfile let textfile_winid = win_getid() *************** *** 1375,1383 **** endfunc func Test_terminal_api_call() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif call WriteApiCall('Tapi_TryThis') let buf = RunVimInTerminal('-S Xscript', {}) --- 1351,1357 ---- endfunc func Test_terminal_api_call() ! CheckRunVimInTerminal call WriteApiCall('Tapi_TryThis') let buf = RunVimInTerminal('-S Xscript', {}) *************** *** 1392,1400 **** endfunc func Test_terminal_api_call_fails() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif call WriteApiCall('TryThis') call ch_logfile('Xlog', 'w') --- 1366,1372 ---- endfunc func Test_terminal_api_call_fails() ! CheckRunVimInTerminal call WriteApiCall('TryThis') call ch_logfile('Xlog', 'w') *************** *** 1418,1426 **** endfunc func Test_terminal_api_call_fail_delete() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif call WriteApiCall('Tapi_Delete') let buf = RunVimInTerminal('-S Xscript', {}) --- 1390,1396 ---- endfunc func Test_terminal_api_call_fail_delete() ! CheckRunVimInTerminal call WriteApiCall('Tapi_Delete') let buf = RunVimInTerminal('-S Xscript', {}) *************** *** 1513,1521 **** endfunc func Test_terminal_all_ansi_colors() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif " Use all the ANSI colors. call writefile([ --- 1483,1489 ---- endfunc func Test_terminal_all_ansi_colors() ! CheckRunVimInTerminal " Use all the ANSI colors. call writefile([ *************** *** 1570,1578 **** endfunc func Test_terminal_termwinsize_option_fixed() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif set termwinsize=6x40 let text = [] for n in range(10) --- 1538,1544 ---- endfunc func Test_terminal_termwinsize_option_fixed() ! CheckRunVimInTerminal set termwinsize=6x40 let text = [] for n in range(10) *************** *** 2034,2042 **** endfunc func Test_terminal_getwinpos() ! if !CanRunVimInTerminal() ! throw 'Skipped: cannot run Vim in a terminal window' ! endif " split, go to the bottom-right window split --- 2000,2006 ---- endfunc func Test_terminal_getwinpos() ! CheckRunVimInTerminal " split, go to the bottom-right window split *** ../vim-8.1.2065/src/misc1.c 2019-09-21 20:46:14.724275765 +0200 --- src/misc1.c 2019-09-22 21:17:31.454781069 +0200 *************** *** 1297,1303 **** may_add_state_char(&ga, include, 'o'); if (autocmd_busy) may_add_state_char(&ga, include, 'x'); ! if (!ctrl_x_mode_none()) may_add_state_char(&ga, include, 'a'); # ifdef FEAT_JOB_CHANNEL --- 1297,1303 ---- may_add_state_char(&ga, include, 'o'); if (autocmd_busy) may_add_state_char(&ga, include, 'x'); ! if (ins_compl_active()) may_add_state_char(&ga, include, 'a'); # ifdef FEAT_JOB_CHANNEL *** ../vim-8.1.2065/src/version.c 2019-09-22 14:11:42.796083779 +0200 --- src/version.c 2019-09-22 20:21:13.509381698 +0200 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 2066, /**/ -- "To whoever finds this note - I have been imprisoned by my father who wishes me to marry against my will. Please please please please come and rescue me. I am in the tall tower of Swamp Castle." SIR LAUNCELOT's eyes light up with holy inspiration. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///