Skip to content

Commit e4d4c12

Browse files
committed
⚓️ work in progress Wed Jan 21 19:37:10 2026
1 parent 5666b18 commit e4d4c12

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lua/search-replace/dashboard.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@ function M.setup()
649649
local cmdline = vim.fn.getcmdline()
650650
-- Quick check: does it look like a substitute command?
651651
if not utils.is_substitute_cmd(cmdline) then
652-
-- Not a substitute command, close dashboard if open
652+
-- Not a substitute command - always clear cache and close dashboard if open
653+
dashboard_state.last_parsed = nil
653654
if float_is_shown() then
654655
M.close_dashboard()
655656
end

lua/search-replace/utils.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,16 @@ function M.trigger_cmdline_refresh(invalidate_fn)
128128
if invalidate_fn then
129129
invalidate_fn()
130130
end
131-
vim.fn.feedkeys(' ' .. vim.keycode('<BS>'), 'in')
131+
-- Save cursor position before triggering refresh
132+
local pos = vim.fn.getcmdpos()
133+
local cmd_len = #vim.fn.getcmdline()
134+
-- Calculate how many <Left> keys needed to restore position after going to end
135+
local chars_to_move_left = cmd_len - pos + 1
136+
137+
-- Go to end (to avoid inserting space in middle), insert space, delete it,
138+
-- then move back to original position
139+
local restore_keys = string.rep(vim.keycode('<Left>'), chars_to_move_left)
140+
vim.fn.feedkeys(vim.keycode('<End>') .. ' ' .. vim.keycode('<BS>') .. restore_keys, 'in')
132141
end, 50)
133142
end
134143

0 commit comments

Comments
 (0)