mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
feat(mappings): considering map description when filtering (#17423)
This commit is contained in:
parent
deb33a9775
commit
9a74c2b04a
@ -502,7 +502,7 @@ Note: When using mappings for Visual mode, you can use the "'<" mark, which
|
||||
is the start of the last selected Visual area in the current buffer |'<|.
|
||||
|
||||
The |:filter| command can be used to select what mappings to list. The
|
||||
pattern is matched against the {lhs} and {rhs} in the raw form.
|
||||
pattern is matched against the {lhs}, {rhs} and {desc} in the raw form.
|
||||
|
||||
*:map-verbose*
|
||||
When 'verbose' is non-zero, listing a key map will also display where it was
|
||||
|
@ -3433,8 +3433,8 @@ static void showmap(mapblock_T *mp, bool local)
|
||||
{
|
||||
size_t len = 1;
|
||||
|
||||
if (message_filtered(mp->m_keys)
|
||||
&& mp->m_str != NULL && message_filtered(mp->m_str)) {
|
||||
if (message_filtered(mp->m_keys) && message_filtered(mp->m_str)
|
||||
&& (mp->m_desc == NULL || message_filtered((char_u *)mp->m_desc))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -877,6 +877,24 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
eq("\nn lhs rhs\n map description",
|
||||
helpers.exec_capture("nmap lhs"))
|
||||
end)
|
||||
|
||||
it ('can :filter maps based on description', function()
|
||||
meths.set_keymap('n', 'asdf1', 'qwert', {desc='do the one thing'})
|
||||
meths.set_keymap('n', 'asdf2', 'qwert', {desc='doesnot really do anything'})
|
||||
meths.set_keymap('n', 'asdf3', 'qwert', {desc='do the other thing'})
|
||||
eq([[
|
||||
|
||||
n asdf3 qwert
|
||||
do the other thing
|
||||
n asdf1 qwert
|
||||
do the one thing]],
|
||||
helpers.exec_capture('filter the nmap'))
|
||||
end)
|
||||
|
||||
it ('shows <nop> as map rhs', function()
|
||||
meths.set_keymap('n', 'asdf', '<nop>', {})
|
||||
eq('\nn asdf <Nop>', helpers.exec_capture('nmap asdf'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
@ -1037,9 +1055,4 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
eq(1, exec_lua[[return GlobalCount]])
|
||||
eq('\nNo mapping found', helpers.exec_capture('nmap asdf'))
|
||||
end)
|
||||
|
||||
it ('shows <nop> as map rhs', function()
|
||||
meths.set_keymap('n', 'asdf', '<nop>', {})
|
||||
eq('\nn asdf <Nop>', helpers.exec_capture('nmap asdf'))
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user