neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 8323398bc6081af3f79b220b886e3c0373129c7e
parent 6a929b15c9e8ee3cada988e8393a9fd8c209db8b
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu,  5 Dec 2024 19:03:58 +0800

fix(defaults): don't replace keycodes in Visual search mappings (#31460)

Also remove "silent" to be more consistent with Normal mode search.
Diffstat:
Mruntime/lua/vim/_defaults.lua | 4++--
Mtest/functional/editor/defaults_spec.lua | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua @@ -49,10 +49,10 @@ do vim.keymap.set('x', '*', function() return _visual_search('/') - end, { desc = ':help v_star-default', expr = true, silent = true }) + end, { desc = ':help v_star-default', expr = true, replace_keycodes = false }) vim.keymap.set('x', '#', function() return _visual_search('?') - end, { desc = ':help v_#-default', expr = true, silent = true }) + end, { desc = ':help v_#-default', expr = true, replace_keycodes = false }) end --- Map Y to y$. This mimics the behavior of D and C. See |Y-default| diff --git a/test/functional/editor/defaults_spec.lua b/test/functional/editor/defaults_spec.lua @@ -94,6 +94,74 @@ describe('default', function() end) describe('key mappings', function() + describe('Visual mode search mappings', function() + it('handle various chars properly', function() + n.clear({ args_rm = { '--cmd' } }) + local screen = Screen.new(60, 8) + screen:set_default_attr_ids({ + [1] = { foreground = Screen.colors.NvimDarkGray4 }, + [2] = { + foreground = Screen.colors.NvimDarkGray3, + background = Screen.colors.NvimLightGray3, + }, + [3] = { + foreground = Screen.colors.NvimLightGrey1, + background = Screen.colors.NvimDarkYellow, + }, + [4] = { + foreground = Screen.colors.NvimDarkGrey1, + background = Screen.colors.NvimLightYellow, + }, + }) + n.api.nvim_buf_set_lines(0, 0, -1, true, { + [[testing <CR> /?\!1]], + [[testing <CR> /?\!2]], + [[testing <CR> /?\!3]], + [[testing <CR> /?\!4]], + }) + n.feed('gg0vf!o*') + screen:expect([[ + {3:testing <CR> /?\!}1 | + {4:^testing <CR> /?\!}2 | + {3:testing <CR> /?\!}3 | + {3:testing <CR> /?\!}4 | + {1:~ }|*2 + {2:[No Name] [+] 2,1 All}| + /\Vtesting <CR> \/?\\! [2/4] | + ]]) + n.feed('n') + screen:expect([[ + {3:testing <CR> /?\!}1 | + {3:testing <CR> /?\!}2 | + {4:^testing <CR> /?\!}3 | + {3:testing <CR> /?\!}4 | + {1:~ }|*2 + {2:[No Name] [+] 3,1 All}| + /\Vtesting <CR> \/?\\! [3/4] | + ]]) + n.feed('G0vf!o#') + screen:expect([[ + {3:testing <CR> /?\!}1 | + {3:testing <CR> /?\!}2 | + {4:^testing <CR> /?\!}3 | + {3:testing <CR> /?\!}4 | + {1:~ }|*2 + {2:[No Name] [+] 3,1 All}| + ?\Vtesting <CR> /?\\! [3/4] | + ]]) + n.feed('n') + screen:expect([[ + {3:testing <CR> /?\!}1 | + {4:^testing <CR> /?\!}2 | + {3:testing <CR> /?\!}3 | + {3:testing <CR> /?\!}4 | + {1:~ }|*2 + {2:[No Name] [+] 2,1 All}| + ?\Vtesting <CR> /?\\! [2/4] | + ]]) + end) + end) + describe('unimpaired-style mappings', function() it('show the command ouptut when successful', function() n.clear({ args_rm = { '--cmd' } })