diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-18 06:23:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-18 06:23:11 +0800 |
commit | 562719033ec8bec9f6d56c166b9aef13f8a50a96 (patch) | |
tree | cef907a538f9bbcf31c5072dedd9842e3f5ff40f /test/functional/legacy/mapping_spec.lua | |
parent | de6eb96fc92ed73237080c1d6a342844fda036fc (diff) | |
download | rneovim-562719033ec8bec9f6d56c166b9aef13f8a50a96.tar.gz rneovim-562719033ec8bec9f6d56c166b9aef13f8a50a96.tar.bz2 rneovim-562719033ec8bec9f6d56c166b9aef13f8a50a96.zip |
vim-patch:9.1.0343: 'showcmd' wrong for partial mapping with multibyte (#28392)
Problem: 'showcmd' is wrong for partial mapping with multibyte char,
and isn't very readable with modifyOtherKeys.
Solution: Decode multibyte char and merge modifiers into the char.
(zeertzjq)
This improves the following situations:
- Multibyte chars whose individual bytes are considered unprintable are
now shown properly in 'showcmd' area.
- Ctrl-W with modifyOtherKeys now shows ^W in 'showcmd' area.
The following situation may still need improvement:
- If the char is a special key or has modifiers that cannot be merged
into it, internal keycodes are shown in 'showcmd' area like before.
This applies to keys typed in Normal mode commands as well, and it's
hard to decide how to make it more readable due to the limited space
taken by 'showcmd', so I'll leave it for later.
closes: vim/vim#14572
https://github.com/vim/vim/commit/acdfb8a97995e0f81832207e39564ba795281108
Diffstat (limited to 'test/functional/legacy/mapping_spec.lua')
-rw-r--r-- | test/functional/legacy/mapping_spec.lua | 76 |
1 files changed, 73 insertions, 3 deletions
diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 272a79fa29..1078daec64 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -1,9 +1,11 @@ -- Test for mappings and abbreviations local t = require('test.functional.testutil')() +local Screen = require('test.functional.ui.screen') local clear, feed, insert = t.clear, t.feed, t.insert local expect, poke_eventloop = t.expect, t.poke_eventloop local command, eq, eval, api = t.command, t.eq, t.eval, t.api +local exec = t.exec local sleep = vim.uv.sleep describe('mapping', function() @@ -23,6 +25,7 @@ describe('mapping', function() vim ]]) end) + -- oldtest: Test_map_ctrl_c_insert() it('Ctrl-c works in Insert mode', function() -- Mapping of ctrl-c in insert mode command('set cpo-=< cpo-=k') @@ -41,6 +44,7 @@ describe('mapping', function() ]]) end) + -- oldtest: Test_map_ctrl_c_visual() it('Ctrl-c works in Visual mode', function() command([[vnoremap <c-c> :<C-u>$put ='vmap works'<cr>]]) feed('GV') @@ -83,6 +87,7 @@ describe('mapping', function() +]]) end) + -- oldtest: Test_map_feedkeys() it('feedkeys', function() insert([[ a b c d @@ -100,6 +105,7 @@ describe('mapping', function() ]]) end) + -- oldtest: Test_map_cursor() it('i_CTRL-G_U', function() -- <c-g>U<cursor> works only within a single line command('imapclear') @@ -128,7 +134,8 @@ describe('mapping', function() ]]) end) - it('dragging starts Select mode even if coming from mapping vim-patch:8.2.4806', function() + -- oldtest: Test_mouse_drag_mapped_start_select() + it('dragging starts Select mode even if coming from mapping', function() command('set mouse=a') command('set selectmode=mouse') @@ -141,7 +148,8 @@ describe('mapping', function() eq('s', eval('mode()')) end) - it('<LeftDrag> mapping in Insert mode works correctly vim-patch:8.2.4692', function() + -- oldtest: Test_mouse_drag_insert_map() + it('<LeftDrag> mapping in Insert mode works correctly', function() command('set mouse=a') command('inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>') @@ -165,7 +173,8 @@ describe('mapping', function() eq('n', eval('mode()')) end) - it('timeout works after an <Nop> mapping is triggered on timeout vim-patch:8.1.0052', function() + -- oldtest: Test_map_after_timed_out_nop() + it('timeout works after an <Nop> mapping is triggered on timeout', function() command('set timeout timeoutlen=400') command('inoremap ab TEST') command('inoremap a <Nop>') @@ -181,4 +190,65 @@ describe('mapping', function() feed('b') expect('TEST') end) + + -- oldtest: Test_showcmd_part_map() + it("'showcmd' with a partial mapping", function() + local screen = Screen.new(60, 6) + screen:attach() + exec([[ + set notimeout showcmd + nnoremap ,a <Ignore> + nnoremap ;a <Ignore> + nnoremap Àa <Ignore> + nnoremap Ëa <Ignore> + nnoremap βa <Ignore> + nnoremap ωa <Ignore> + nnoremap …a <Ignore> + nnoremap <C-W>a <Ignore> + ]]) + + for _, c in ipairs({ ',', ';', 'À', 'Ë', 'β', 'ω', '…' }) do + feed(c) + screen:expect(([[ + ^ | + {1:~ }|*4 + %s | + ]]):format(c)) + feed('<C-C>') + command('echo') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + end + + feed('\23') + screen:expect([[ + ^ | + {1:~ }|*4 + ^W | + ]]) + feed('<C-C>') + command('echo') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + + feed('<C-W>') + screen:expect([[ + ^ | + {1:~ }|*4 + ^W | + ]]) + feed('<C-C>') + command('echo') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + end) end) |