To: vim_dev@googlegroups.com Subject: Patch 9.0.0500 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0500 Problem: When quitting the cmdline window with CTRL-C it remains visible. Solution: Redraw to avoid confusion. Adjust the error message. (closes #11152) Adjust the cursor position after CTRL-C. Files: src/ex_getln.c, src/errors.h, src/testdir/test_cmdwin.vim, src/testdir/dumps/Test_cmdwin_wrong_command_1.dump, src/testdir/dumps/Test_cmdwin_wrong_command_2.dump *** ../vim-9.0.0499/src/ex_getln.c 2022-09-17 19:43:19.254427034 +0100 --- src/ex_getln.c 2022-09-18 14:54:13.020741003 +0100 *************** *** 4631,4643 **** ccline.cmdlen = (int)STRLEN(ccline.cmdbuff); ccline.cmdbufflen = ccline.cmdlen + 1; ccline.cmdpos = curwin->w_cursor.col; ! if (ccline.cmdpos > ccline.cmdlen) ccline.cmdpos = ccline.cmdlen; - if (cmdwin_result == K_IGNORE) - { - set_cmdspos_cursor(); - redrawcmd(); - } } # ifdef FEAT_CONCEAL --- 4631,4641 ---- ccline.cmdlen = (int)STRLEN(ccline.cmdbuff); ccline.cmdbufflen = ccline.cmdlen + 1; ccline.cmdpos = curwin->w_cursor.col; ! // If the cursor is on the last character, it probably should be ! // after it. ! if (ccline.cmdpos == ccline.cmdlen - 1 ! || ccline.cmdpos > ccline.cmdlen) ccline.cmdpos = ccline.cmdlen; } # ifdef FEAT_CONCEAL *************** *** 4664,4669 **** --- 4662,4676 ---- // Restore window sizes. win_size_restore(&winsizes); skip_win_fix_cursor = FALSE; + + if (cmdwin_result == K_IGNORE) + { + // It can be confusing that the cmdwin still shows, redraw the + // screen. + update_screen(UPD_VALID); + set_cmdspos_cursor(); + redrawcmd(); + } } ga_clear(&winsizes); *** ../vim-9.0.0499/src/errors.h 2022-09-17 21:07:52.103993150 +0100 --- src/errors.h 2022-09-18 14:43:37.278218001 +0100 *************** *** 17,23 **** INIT(= N_("E10: \\ should be followed by /, ? or &")); #ifdef FEAT_CMDWIN EXTERN char e_invalid_in_cmdline_window[] ! INIT(= N_("E11: Invalid in command-line window; executes, CTRL-C quits")); #endif EXTERN char e_command_not_allowed_from_vimrc_in_current_dir_or_tag_search[] INIT(= N_("E12: Command not allowed from exrc/vimrc in current dir or tag search")); --- 17,23 ---- INIT(= N_("E10: \\ should be followed by /, ? or &")); #ifdef FEAT_CMDWIN EXTERN char e_invalid_in_cmdline_window[] ! INIT(= N_("E11: Invalid in command-line window; :q closes the window")); #endif EXTERN char e_command_not_allowed_from_vimrc_in_current_dir_or_tag_search[] INIT(= N_("E12: Command not allowed from exrc/vimrc in current dir or tag search")); *** ../vim-9.0.0499/src/testdir/test_cmdwin.vim 2022-09-17 21:20:38.646360597 +0100 --- src/testdir/test_cmdwin.vim 2022-09-18 14:55:43.240527208 +0100 *************** *** 73,79 **** call writefile(lines, 'XTest_restore', 'D') let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12}) - call TermWait(buf, 50) call term_sendkeys(buf, "q:") call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {}) --- 73,78 ---- *************** *** 93,103 **** endfunc func Test_cmdwin_no_terminal() ! CheckFeature terminal ! CheckNotMSWindows let buf = RunVimInTerminal('', {'rows': 12}) - call TermWait(buf, 50) call term_sendkeys(buf, ":set cmdheight=2\") call term_sendkeys(buf, "q:") call term_sendkeys(buf, ":let buf = term_start(['/bin/echo'], #{hidden: 1})\") --- 92,100 ---- endfunc func Test_cmdwin_no_terminal() ! CheckScreendump let buf = RunVimInTerminal('', {'rows': 12}) call term_sendkeys(buf, ":set cmdheight=2\") call term_sendkeys(buf, "q:") call term_sendkeys(buf, ":let buf = term_start(['/bin/echo'], #{hidden: 1})\") *************** *** 105,110 **** --- 102,123 ---- call term_sendkeys(buf, ":q\") call StopVimInTerminal(buf) endfunc + + func Test_cmdwin_wrong_command() + CheckScreendump + + let buf = RunVimInTerminal('', {'rows': 12}) + call term_sendkeys(buf, "q:") + call term_sendkeys(buf, "als\") + call term_sendkeys(buf, "\k") + call VerifyScreenDump(buf, 'Test_cmdwin_wrong_command_1', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_cmdwin_wrong_command_2', {}) + + call term_sendkeys(buf, ":q\") + call StopVimInTerminal(buf) + endfunc func Test_cmdwin_feedkeys() " This should not generate E488 *** ../vim-9.0.0499/src/testdir/dumps/Test_cmdwin_wrong_command_1.dump 2022-09-18 15:02:59.651536793 +0100 --- src/testdir/dumps/Test_cmdwin_wrong_command_1.dump 2022-09-18 14:55:48.140515578 +0100 *************** *** 0 **** --- 1,12 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 + |:+0#4040ff13&|l+0#af5f00255&>s| +0#0000000&@71 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |[+3#0000000&|C|o|m@1|a|n|d| |L|i|n|e|]| @42|1|,|2| @11|A|l@1 + |E+0#ffffff16#e000002|1@1|:| |I|n|v|a|l|i|d| |i|n| |c|o|m@1|a|n|d|-|l|i|n|e| |w|i|n|d|o|w|;| |:|q|<|C|R|>| |c|l|o|s|e|s| |t|h|e| |w|i|n|d|o|w| +0#0000000#ffffff0@13 *** ../vim-9.0.0499/src/testdir/dumps/Test_cmdwin_wrong_command_2.dump 2022-09-18 15:02:59.655536786 +0100 --- src/testdir/dumps/Test_cmdwin_wrong_command_2.dump 2022-09-18 14:55:49.296512831 +0100 *************** *** 0 **** --- 1,12 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |:+0#0000000&|l|s> @71 *** ../vim-9.0.0499/src/version.c 2022-09-18 13:46:03.699664837 +0100 --- src/version.c 2022-09-18 14:29:41.535907612 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 500, /**/ -- A fool learns from his mistakes, a wise man from someone else's. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///