From 969d600f2a107507c60e4ac3f3a8c03210662f96 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 5 Apr 2022 21:38:53 +0800 Subject: vim-patch:8.2.{4692,4691,4690}: fix Insert mode mapping bug (#17999) vim-patch:8.2.4692: no test for what 8.2.4691 fixes Problem: No test for what 8.2.4691 fixes. Solution: Add a test. Use a more generic sotlution. (closes vim/vim#10090) https://github.com/vim/vim/commit/0f68e6c07aaf62c034a242f183b93c1bb44e7f93 Test cannot be used because it must use test_setmouse(). Use a Lua test. Reverted patches: vim-patch:8.2.4691: solution for in a mapping causes trouble Problem: Solution for in a mapping causes trouble. Solution: Use another solution: put back CTRL-O after reading the sequence. https://github.com/vim/vim/commit/ca9d8d2cb9fc6b9240f2a74ccd36f9d966488294 vim-patch:8.2.4689: using in a mapping does not work for mouse keys Problem: Using in a mapping does not work for mouse keys in Insert mode. (Sergey Vlasov) Solution: When reading the argument do not use the stuff buffer. (closes vim/vim#10080) https://github.com/vim/vim/commit/d0fb2d804183c2786578b4c32ba5b92938f93d0e --- test/functional/legacy/mapping_spec.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/functional/legacy/mapping_spec.lua') diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 92a757ca85..aa29698589 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -3,6 +3,8 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local feed_command, expect, poke_eventloop = helpers.feed_command, helpers.expect, helpers.poke_eventloop +local command, eq, eval, meths = helpers.command, helpers.eq, helpers.eval, helpers.meths +local sleep = helpers.sleep describe('mapping', function() before_each(clear) @@ -126,4 +128,28 @@ describe('mapping', function() new line here ]]) end) + + it(' mapping in Insert mode works correctly vim-patch:8.2.4692', function() + command('set mouse=a') + + command([[inoremap let g:dragged = 1]]) + feed('i') + sleep(10) + meths.input_mouse('left', 'press', '', 0, 0, 0) + sleep(10) + meths.input_mouse('left', 'drag', '', 0, 0, 1) + sleep(10) + eq(1, eval('g:dragged')) + eq('v', eval('mode()')) + feed([[]]) + + command([[inoremap ]]) + feed('i') + sleep(10) + meths.input_mouse('left', 'press', '', 0, 0, 0) + sleep(10) + meths.input_mouse('left', 'drag', '', 0, 0, 1) + sleep(10) + eq('n', eval('mode()')) + end) end) -- cgit