1
0
forked from aniani/vim

patch 9.1.0343: 'showcmd' wrong for partial mapping with multibyte

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: #14572

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-04-17 21:28:54 +02:00
committed by Christian Brabandt
parent ae7e61c928
commit acdfb8a979
4 changed files with 202 additions and 66 deletions

View File

@@ -1807,6 +1807,48 @@ func Test_map_after_timed_out_nop()
call StopVimInTerminal(buf)
endfunc
" Test 'showcmd' behavior with a partial mapping
func Test_showcmd_part_map()
CheckRunVimInTerminal
let lines =<< trim eval END
set notimeout showcmd
nnoremap ,a <Ignore>
nnoremap ;a <Ignore>
nnoremap Àa <Ignore>
nnoremap Ëa <Ignore>
nnoremap βa <Ignore>
nnoremap ωa <Ignore>
nnoremapa <Ignore>
nnoremap <C-W>a <Ignore>
END
call writefile(lines, 'Xtest_showcmd_part_map', 'D')
let buf = RunVimInTerminal('-S Xtest_showcmd_part_map', #{rows: 6})
call term_sendkeys(buf, ":set noruler | echo\<CR>")
call WaitForAssert({-> assert_equal('', term_getline(buf, 6))})
for c in [',', ';', 'À', 'Ë', 'β', 'ω', '…']
call term_sendkeys(buf, c)
call WaitForAssert({-> assert_equal(c, trim(term_getline(buf, 6)))})
call term_sendkeys(buf, "\<C-C>:echo\<CR>")
call WaitForAssert({-> assert_equal('', term_getline(buf, 6))})
endfor
call term_sendkeys(buf, "\<C-W>")
call WaitForAssert({-> assert_equal('^W', trim(term_getline(buf, 6)))})
call term_sendkeys(buf, "\<C-C>:echo\<CR>")
call WaitForAssert({-> assert_equal('', term_getline(buf, 6))})
" Use feedkeys() as terminal buffer cannot forward this
call term_sendkeys(buf, ':call feedkeys("\<*C-W>", "m")' .. " | echo\<CR>")
call WaitForAssert({-> assert_equal('^W', trim(term_getline(buf, 6)))})
call term_sendkeys(buf, "\<C-C>:echo\<CR>")
call WaitForAssert({-> assert_equal('', term_getline(buf, 6))})
call StopVimInTerminal(buf)
endfunc
func Test_using_past_typeahead()
nnoremap :00 0
exe "norm :set \x80\xfb0=0\<CR>"