mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	vim-patch:9.0.1385: g'Esc is considered an error (#22544)
Problem:    g'Esc is considered an error.
Solution:   Make g'Esc silently abandon the command. (closes vim/vim#12110)
f86dea8119
			
			
This commit is contained in:
		| @@ -963,7 +963,8 @@ normal_end: | ||||
|   may_trigger_modechanged(); | ||||
|   // Redraw the cursor with another shape, if we were in Operator-pending | ||||
|   // mode or did a replace command. | ||||
|   if (s->c || s->ca.cmdchar == 'r') { | ||||
|   if (s->c || s->ca.cmdchar == 'r' | ||||
|       || (s->ca.cmdchar == 'g' && s->ca.nchar == 'r')) { | ||||
|     ui_cursor_shape();                  // may show different cursor shape | ||||
|   } | ||||
|  | ||||
| @@ -1162,7 +1163,7 @@ static int normal_execute(VimState *state, int key) | ||||
|  | ||||
|   State = MODE_NORMAL; | ||||
|  | ||||
|   if (s->ca.nchar == ESC) { | ||||
|   if (s->ca.nchar == ESC || s->ca.extra_char == ESC) { | ||||
|     clearop(&s->oa); | ||||
|     s->command_finished = true; | ||||
|     goto finish; | ||||
| @@ -4706,7 +4707,7 @@ static void nv_vreplace(cmdarg_T *cap) | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   if (checkclearopq(cap->oap) || cap->extra_char == ESC) { | ||||
|   if (checkclearopq(cap->oap)) { | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -2540,6 +2540,8 @@ func Test_normal33_g_cmd2() | ||||
|   norm! g'a | ||||
|   call assert_equal('>', a[-1:]) | ||||
|   call assert_equal(1, line('.')) | ||||
|   call assert_nobeep("normal! g`\<Esc>") | ||||
|   call assert_nobeep("normal! g'\<Esc>") | ||||
|  | ||||
|   " Test for g; and g, | ||||
|   norm! g; | ||||
| @@ -3315,7 +3317,8 @@ func Test_gr_command() | ||||
|   set modifiable& | ||||
|  | ||||
|   call assert_nobeep("normal! gr\<Esc>") | ||||
|   call assert_beeps("normal! cgr\<Esc>") | ||||
|   call assert_nobeep("normal! cgr\<Esc>") | ||||
|   call assert_beeps("normal! cgrx") | ||||
|  | ||||
|   call assert_equal('zxxxx line    l', getline(1)) | ||||
|   exe "normal! 2|gr\<C-V>\<Esc>" | ||||
| @@ -3895,4 +3898,36 @@ func Test_mouse_shape_after_failed_change() | ||||
|   call delete('Xmouseshapes') | ||||
| endfunc | ||||
|  | ||||
| " Test that mouse shape is restored to Normal mode after cancelling "gr". | ||||
| func Test_mouse_shape_after_cancelling_gr() | ||||
|   CheckFeature mouseshape | ||||
|   CheckCanRunGui | ||||
|  | ||||
|   let lines =<< trim END | ||||
|     vim9script | ||||
|     var mouse_shapes = [] | ||||
|  | ||||
|     feedkeys('gr') | ||||
|     timer_start(50, (_) => { | ||||
|       mouse_shapes += [getmouseshape()] | ||||
|       timer_start(50, (_) => { | ||||
|         feedkeys("\<Esc>") | ||||
|         timer_start(50, (_) => { | ||||
|           mouse_shapes += [getmouseshape()] | ||||
|           timer_start(50, (_) => { | ||||
|             writefile(mouse_shapes, 'Xmouseshapes') | ||||
|             quit | ||||
|           }) | ||||
|         }) | ||||
|       }) | ||||
|     }) | ||||
|   END | ||||
|   call writefile(lines, 'Xmouseshape.vim', 'D') | ||||
|   call RunVim([], [], "-g -S Xmouseshape.vim") | ||||
|   sleep 300m | ||||
|   call assert_equal(['beam', 'arrow'], readfile('Xmouseshapes')) | ||||
|  | ||||
|   call delete('Xmouseshapes') | ||||
| endfunc | ||||
|  | ||||
| " vim: shiftwidth=2 sts=2 expandtab | ||||
|   | ||||
| @@ -44,7 +44,10 @@ describe('ui mode_change event', function() | ||||
|       {0:~                        }| | ||||
|                                | | ||||
|     ]], mode="normal"} | ||||
|   end) | ||||
|  | ||||
|   -- oldtest: Test_mouse_shape_after_failed_change() | ||||
|   it('is restored to Normal mode after failed "c"', function() | ||||
|     screen:try_resize(50, 4) | ||||
|     command('set nomodifiable') | ||||
|  | ||||
| @@ -65,6 +68,25 @@ describe('ui mode_change event', function() | ||||
|     ]], mode="normal"} | ||||
|   end) | ||||
|  | ||||
|   -- oldtest: Test_mouse_shape_after_cancelling_gr() | ||||
|   it('is restored to Normal mode after cancelling "gr"', function() | ||||
|     feed('gr') | ||||
|     screen:expect{grid=[[ | ||||
|       ^                         | | ||||
|       {0:~                        }| | ||||
|       {0:~                        }| | ||||
|                                | | ||||
|     ]], mode="replace"} | ||||
|  | ||||
|     feed('<Esc>') | ||||
|     screen:expect{grid=[[ | ||||
|       ^                         | | ||||
|       {0:~                        }| | ||||
|       {0:~                        }| | ||||
|                                | | ||||
|     ]], mode="normal"} | ||||
|   end) | ||||
|  | ||||
|   it('works in insert mode', function() | ||||
|     feed('i') | ||||
|     screen:expect{grid=[[ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user