From 4174e5dfb9051a30158c4319b700cbf2ae023a4f Mon Sep 17 00:00:00 2001 From: korigamik Date: Fri, 19 Jun 2026 02:59:17 +0530 Subject: [PATCH 1/2] fix(nvim): keep prompt icon when clearing input with cc/S In prompt_vim_mode the input bar is a prompt buffer whose prompt icon is protected text at the start of the line. A normal-mode cc/S deletes the whole line including the prompt, so Neovim re-inserts the icon as plain literal text that has to be backspaced out. Map cc and S to reset the line to just the prompt and re-enter insert at the right column, so clearing the query leaves the prompt intact. --- lua/fff/picker_ui/ui_creator.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lua/fff/picker_ui/ui_creator.lua b/lua/fff/picker_ui/ui_creator.lua index c3c62040..b16f45d4 100644 --- a/lua/fff/picker_ui/ui_creator.lua +++ b/lua/fff/picker_ui/ui_creator.lua @@ -357,6 +357,22 @@ function M.setup_keymaps() if S.config.prompt_vim_mode then set_keymap('n', keymaps.close, P.close, input_opts) set_keymap('i', '', P.close, input_opts) + + -- cc/S clear the whole line, wiping the prompt buffer's prompt and leaving + -- a stray icon behind. Reset to just the prompt and re-enter insert instead. + local function clear_query_line() + local prompt = S.config.prompt + vim.api.nvim_set_option_value('modifiable', true, { buf = S.input_buf }) + vim.api.nvim_buf_set_lines(S.input_buf, 0, -1, false, { prompt }) + vim.schedule(function() + if S.input_win and vim.api.nvim_win_is_valid(S.input_win) then + vim.api.nvim_win_set_cursor(S.input_win, { 1, #prompt }) + vim.cmd('startinsert!') + end + end) + end + set_keymap('n', 'cc', clear_query_line, input_opts) + set_keymap('n', 'S', clear_query_line, input_opts) else set_keymap({ 'i', 'n' }, keymaps.close, P.close, input_opts) end From ea025ce8bf348b8be8c7cd3a18ddf1fa65568f15 Mon Sep 17 00:00:00 2001 From: korigamik Date: Fri, 19 Jun 2026 10:41:59 +0530 Subject: [PATCH 2/2] fix(nvim): allow remap of cc/S clear bindings in prompt vim mode Pass remap=true so existing user mappings of cc/S still resolve through our handler, per review feedback. --- lua/fff/picker_ui/ui_creator.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/fff/picker_ui/ui_creator.lua b/lua/fff/picker_ui/ui_creator.lua index b16f45d4..c6bac4e0 100644 --- a/lua/fff/picker_ui/ui_creator.lua +++ b/lua/fff/picker_ui/ui_creator.lua @@ -371,8 +371,10 @@ function M.setup_keymaps() end end) end - set_keymap('n', 'cc', clear_query_line, input_opts) - set_keymap('n', 'S', clear_query_line, input_opts) + -- remap=true so existing user mappings of cc/S still resolve + local clear_opts = vim.tbl_extend('force', input_opts, { noremap = false, remap = true }) + set_keymap('n', 'cc', clear_query_line, clear_opts) + set_keymap('n', 'S', clear_query_line, clear_opts) else set_keymap({ 'i', 'n' }, keymaps.close, P.close, input_opts) end