mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	Merge pull request #16792 from zeertzjq/ins-lastc-k-event
fix: do not save K_EVENT as lastc in Insert mode
This commit is contained in:
		| @@ -643,7 +643,10 @@ static int insert_check(VimState *state) | |||||||
|   update_curswant(); |   update_curswant(); | ||||||
|   s->old_topline = curwin->w_topline; |   s->old_topline = curwin->w_topline; | ||||||
|   s->old_topfill = curwin->w_topfill; |   s->old_topfill = curwin->w_topfill; | ||||||
|  |  | ||||||
|  |   if (s->c != K_EVENT) { | ||||||
|     s->lastc = s->c;  // remember previous char for CTRL-D |     s->lastc = s->c;  // remember previous char for CTRL-D | ||||||
|  |   } | ||||||
|  |  | ||||||
|   // After using CTRL-G U the next cursor key will not break undo. |   // After using CTRL-G U the next cursor key will not break undo. | ||||||
|   if (dont_sync_undo == kNone) { |   if (dont_sync_undo == kNone) { | ||||||
|   | |||||||
| @@ -1154,8 +1154,8 @@ describe('API', function() | |||||||
|     end) |     end) | ||||||
|   end) |   end) | ||||||
|  |  | ||||||
|   describe('RPC (K_EVENT) #6166', function() |   describe('RPC (K_EVENT)', function() | ||||||
|     it('does not complete ("interrupt") normal-mode operator-pending', function() |     it('does not complete ("interrupt") normal-mode operator-pending #6166', function() | ||||||
|       helpers.insert([[ |       helpers.insert([[ | ||||||
|         FIRST LINE |         FIRST LINE | ||||||
|         SECOND LINE]]) |         SECOND LINE]]) | ||||||
| @@ -1191,7 +1191,7 @@ describe('API', function() | |||||||
|       ]]) |       ]]) | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     it('does not complete ("interrupt") normal-mode map-pending', function() |     it('does not complete ("interrupt") normal-mode map-pending #6166', function() | ||||||
|       command("nnoremap dd :let g:foo='it worked...'<CR>") |       command("nnoremap dd :let g:foo='it worked...'<CR>") | ||||||
|       helpers.insert([[ |       helpers.insert([[ | ||||||
|         FIRST LINE |         FIRST LINE | ||||||
| @@ -1207,7 +1207,8 @@ describe('API', function() | |||||||
|         SECOND LINE]]) |         SECOND LINE]]) | ||||||
|       eq('it worked...', helpers.eval('g:foo')) |       eq('it worked...', helpers.eval('g:foo')) | ||||||
|     end) |     end) | ||||||
|     it('does not complete ("interrupt") insert-mode map-pending', function() |  | ||||||
|  |     it('does not complete ("interrupt") insert-mode map-pending #6166', function() | ||||||
|       command('inoremap xx foo') |       command('inoremap xx foo') | ||||||
|       command('set timeoutlen=9999') |       command('set timeoutlen=9999') | ||||||
|       helpers.insert([[ |       helpers.insert([[ | ||||||
| @@ -1222,6 +1223,37 @@ describe('API', function() | |||||||
|         FIRST LINE |         FIRST LINE | ||||||
|         SECOND LINfooE]]) |         SECOND LINfooE]]) | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|  |     it('does not interrupt Insert mode i_CTRL-O #10035', function() | ||||||
|  |       feed('iHello World<c-o>') | ||||||
|  |       eq({mode='niI', blocking=false}, meths.get_mode())  -- fast event | ||||||
|  |       eq(2, eval('1+1'))  -- causes K_EVENT key | ||||||
|  |       eq({mode='niI', blocking=false}, meths.get_mode())  -- still in ctrl-o mode | ||||||
|  |       feed('dd') | ||||||
|  |       eq({mode='i', blocking=false}, meths.get_mode())  -- left ctrl-o mode | ||||||
|  |       expect('') -- executed the command | ||||||
|  |     end) | ||||||
|  |  | ||||||
|  |     it('does not interrupt Select mode v_CTRL-O #15688', function() | ||||||
|  |       feed('iHello World<esc>gh<c-o>') | ||||||
|  |       eq({mode='vs', blocking=false}, meths.get_mode())  -- fast event | ||||||
|  |       eq({mode='vs', blocking=false}, meths.get_mode())  -- again #15288 | ||||||
|  |       eq(2, eval('1+1'))  -- causes K_EVENT key | ||||||
|  |       eq({mode='vs', blocking=false}, meths.get_mode())  -- still in ctrl-o mode | ||||||
|  |       feed('^') | ||||||
|  |       eq({mode='s', blocking=false}, meths.get_mode())  -- left ctrl-o mode | ||||||
|  |       feed('h') | ||||||
|  |       eq({mode='i', blocking=false}, meths.get_mode())  -- entered insert mode | ||||||
|  |       expect('h')  -- selection is the whole line and is replaced | ||||||
|  |     end) | ||||||
|  |  | ||||||
|  |     it('does not interrupt Insert mode i_0_CTRL-D #13997', function() | ||||||
|  |       command('set timeoutlen=9999') | ||||||
|  |       feed('i<Tab><Tab>a0') | ||||||
|  |       eq(2, eval('1+1'))  -- causes K_EVENT key | ||||||
|  |       feed('<C-D>') | ||||||
|  |       expect('a')  -- recognized i_0_CTRL-D | ||||||
|  |     end) | ||||||
|   end) |   end) | ||||||
|  |  | ||||||
|   describe('nvim_get_context', function() |   describe('nvim_get_context', function() | ||||||
|   | |||||||
| @@ -6,7 +6,6 @@ local expect = helpers.expect | |||||||
| local command = helpers.command | local command = helpers.command | ||||||
| local eq = helpers.eq | local eq = helpers.eq | ||||||
| local eval = helpers.eval | local eval = helpers.eval | ||||||
| local meths = helpers.meths |  | ||||||
|  |  | ||||||
| describe('insert-mode', function() | describe('insert-mode', function() | ||||||
|   before_each(function() |   before_each(function() | ||||||
| @@ -75,15 +74,5 @@ describe('insert-mode', function() | |||||||
|       feed('ooo') |       feed('ooo') | ||||||
|       expect('hello oooworld') |       expect('hello oooworld') | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     it("doesn't cancel Ctrl-O mode when processing event", function() |  | ||||||
|       feed('iHello World<c-o>') |  | ||||||
|       eq({mode='niI', blocking=false}, meths.get_mode()) -- fast event |  | ||||||
|       eq(2, eval('1+1'))  -- causes K_EVENT key |  | ||||||
|       eq({mode='niI', blocking=false}, meths.get_mode()) -- still in ctrl-o mode |  | ||||||
|       feed('dd') |  | ||||||
|       eq({mode='i', blocking=false}, meths.get_mode()) -- left ctrl-o mode |  | ||||||
|       expect('') -- executed the command |  | ||||||
|     end) |  | ||||||
|   end) |   end) | ||||||
| end) | end) | ||||||
|   | |||||||
| @@ -1,27 +0,0 @@ | |||||||
| -- Visual-mode tests. |  | ||||||
|  |  | ||||||
| local helpers = require('test.functional.helpers')(after_each) |  | ||||||
| local clear = helpers.clear |  | ||||||
| local eq = helpers.eq |  | ||||||
| local eval = helpers.eval |  | ||||||
| local expect = helpers.expect |  | ||||||
| local feed = helpers.feed |  | ||||||
| local meths = helpers.meths |  | ||||||
|  |  | ||||||
| describe('visual-mode', function() |  | ||||||
|   before_each(clear) |  | ||||||
|  |  | ||||||
|   it("select-mode Ctrl-O doesn't cancel Ctrl-O mode when processing event #15688", function() |  | ||||||
|     feed('iHello World<esc>gh<c-o>') |  | ||||||
|     eq({mode='vs', blocking=false}, meths.get_mode()) -- fast event |  | ||||||
|     eq({mode='vs', blocking=false}, meths.get_mode()) -- again #15288 |  | ||||||
|     eq(2, eval('1+1'))  -- causes K_EVENT key |  | ||||||
|     eq({mode='vs', blocking=false}, meths.get_mode()) -- still in ctrl-o mode |  | ||||||
|     feed('^') |  | ||||||
|     eq({mode='s', blocking=false}, meths.get_mode()) -- left ctrl-o mode |  | ||||||
|     feed('h') |  | ||||||
|     eq({mode='i', blocking=false}, meths.get_mode()) -- entered insert mode |  | ||||||
|     expect('h') -- selection is the whole line and is replaced |  | ||||||
|   end) |  | ||||||
| end) |  | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user
	 Björn Linse
					Björn Linse