To: vim_dev@googlegroups.com Subject: Patch 9.0.1356 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1356 Problem: Cannot cancel "gr" with Esc. Solution: Make "gr" do nothing. (closes #12064) Files: src/edit.c, src/normal.c, src/testdir/test_edit.vim, src/testdir/test_normal.vim *** ../vim-9.0.1355/src/edit.c 2023-02-25 14:24:39.573937238 +0000 --- src/edit.c 2023-02-26 14:38:17.184107166 +0000 *************** *** 45,51 **** #endif static int ins_start_select(int c); static void ins_insert(int replaceState); ! static void ins_ctrl_o(int cmdchar); static void ins_shift(int c, int lastc); static void ins_del(void); static int ins_bs(int c, int mode, int *inserted_space_p); --- 45,51 ---- #endif static int ins_start_select(int c); static void ins_insert(int replaceState); ! static void ins_ctrl_o(void); static void ins_shift(int c, int lastc); static void ins_del(void); static int ins_bs(int c, int mode, int *inserted_space_p); *************** *** 429,436 **** /* * Main loop in Insert mode: repeat until Insert mode is left. */ ! int did_loop = FALSE; ! for (;; did_loop = TRUE) { #ifdef FEAT_RIGHTLEFT if (!revins_legal) --- 429,435 ---- /* * Main loop in Insert mode: repeat until Insert mode is left. */ ! for (;;) { #ifdef FEAT_RIGHTLEFT if (!revins_legal) *************** *** 589,596 **** if (cmdchar == K_PS) // Got here from normal mode when bracketed paste started. c = K_PS; - else if (cmdchar == 'v' && did_loop && count <= 0) - c = ESC; // in case the stuffed Esc was consumed already else do { --- 588,593 ---- *************** *** 720,726 **** { if (c == Ctrl_O) { ! ins_ctrl_o(cmdchar); ins_at_eol = FALSE; // cursor keeps its column nomove = TRUE; } --- 717,723 ---- { if (c == Ctrl_O) { ! ins_ctrl_o(); ins_at_eol = FALSE; // cursor keeps its column nomove = TRUE; } *************** *** 863,869 **** #endif if (echeck_abbr(Ctrl_O + ABBR_OFF)) break; ! ins_ctrl_o(cmdchar); // don't move the cursor left when 'virtualedit' has "onemore". if (get_ve_flags() & VE_ONEMORE) --- 860,866 ---- #endif if (echeck_abbr(Ctrl_O + ABBR_OFF)) break; ! ins_ctrl_o(); // don't move the cursor left when 'virtualedit' has "onemore". if (get_ve_flags() & VE_ONEMORE) *************** *** 3855,3864 **** * Pressed CTRL-O in Insert mode. */ static void ! ins_ctrl_o(int cmdchar) { - if (cmdchar == 'v') - return; // abort replacing one char for gr CTRL-O if (State & VREPLACE_FLAG) restart_edit = 'V'; else if (State & REPLACE_FLAG) --- 3852,3859 ---- * Pressed CTRL-O in Insert mode. */ static void ! ins_ctrl_o(void) { if (State & VREPLACE_FLAG) restart_edit = 'V'; else if (State & REPLACE_FLAG) *** ../vim-9.0.1355/src/normal.c 2023-02-25 14:24:39.573937238 +0000 --- src/normal.c 2023-02-26 14:38:17.188107154 +0000 *************** *** 515,521 **** cap->nchar = cap->extra_char; idx = find_command(cap->cmdchar); } ! else if ((cap->nchar == 'n' || cap->nchar == 'N') && cap->cmdchar == 'g') cap->oap->op_type = get_op_type(*cp, NUL); else if (*cp == Ctrl_BSL) { --- 515,522 ---- cap->nchar = cap->extra_char; idx = find_command(cap->cmdchar); } ! else if ((cap->nchar == 'n' || cap->nchar == 'N') ! && cap->cmdchar == 'g') cap->oap->op_type = get_op_type(*cp, NUL); else if (*cp == Ctrl_BSL) { *************** *** 5024,5030 **** return; } ! if (checkclearopq(cap->oap)) return; if (!curbuf->b_p_ma) --- 5025,5031 ---- return; } ! if (checkclearopq(cap->oap) || cap->extra_char == ESC) return; if (!curbuf->b_p_ma) *** ../vim-9.0.1355/src/testdir/test_edit.vim 2023-02-25 14:24:39.573937238 +0000 --- src/testdir/test_edit.vim 2023-02-26 14:38:17.188107154 +0000 *************** *** 573,578 **** --- 573,579 ---- call assert_equal([0, 3, 7, 0], getpos('.')) call feedkeys("i\j\", 'tnix') call assert_equal([0, 3, 6, 0], getpos('.')) + call assert_nobeep("normal! i\\") bw! endfunc *************** *** 2063,2082 **** bwipe! endfunc - - " Test "gr" followed by an Insert mode command does get out of Insert mode. - func Test_edit_gr_special() - enew - call setline(1, ['abcdef', 'xxxxxx']) - exe "normal! gr\lx" - call assert_equal("\def", getline(1)) - - call setline(1, 'abcdef') - exe "normal! 0gr\lx" - call assert_equal("\def", getline(1)) - - bwipe! - endfunc " Weird long file name was going over the end of NameBuff func Test_edit_overlong_file_name() --- 2064,2069 ---- *** ../vim-9.0.1355/src/testdir/test_normal.vim 2023-01-28 19:18:56.729720605 +0000 --- src/testdir/test_normal.vim 2023-02-26 14:45:19.363237545 +0000 *************** *** 3273,3281 **** endfunc " Test for the gr (virtual replace) command - " Test for the bug fixed by 7.4.387 func Test_gr_command() enew! let save_cpo = &cpo call append(0, ['First line', 'Second line', 'Third line']) exe "normal i\u" --- 3273,3281 ---- endfunc " Test for the gr (virtual replace) command func Test_gr_command() enew! + " Test for the bug fixed by 7.4.387 let save_cpo = &cpo call append(0, ['First line', 'Second line', 'Third line']) exe "normal i\u" *************** *** 3288,3297 **** --- 3288,3299 ---- normal 4gro call assert_equal('ooooecond line', getline(2)) let &cpo = save_cpo + normal! ggvegrx call assert_equal('xxxxx line', getline(1)) exe "normal! gggr\122" call assert_equal('zxxxx line', getline(1)) + set virtualedit=all normal! 15|grl call assert_equal('zxxxx line l', getline(1)) *************** *** 3299,3306 **** set nomodifiable call assert_fails('normal! grx', 'E21:') call assert_fails('normal! gRx', 'E21:') set modifiable& ! enew! endfunc func Test_nv_hat_count() --- 3301,3325 ---- set nomodifiable call assert_fails('normal! grx', 'E21:') call assert_fails('normal! gRx', 'E21:') + call assert_nobeep("normal! gr\") set modifiable& ! ! call assert_nobeep("normal! gr\") ! call assert_beeps("normal! cgr\") ! ! call assert_equal('zxxxx line l', getline(1)) ! exe "normal! 2|gr\\" ! call assert_equal("z\xx line l", getline(1)) ! ! call setline(1, 'abcdef') ! exe "normal! 0gr\lx" ! call assert_equal("\def", getline(1)) ! ! call setline(1, 'abcdef') ! exe "normal! 0gr\lx" ! call assert_equal("\def", getline(1)) ! ! bwipe! endfunc func Test_nv_hat_count() *** ../vim-9.0.1355/src/version.c 2023-02-25 19:59:27.892421722 +0000 --- src/version.c 2023-02-26 14:39:56.207825638 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1356, /**/ -- hundred-and-one symptoms of being an internet addict: 184. You no longer ask prospective dates what their sign is, instead your line is "Hi, what's your URL?" /// 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 ///