Skip to content

Commit 71673fd

Browse files
committed
fix shortcut
1 parent 25214d2 commit 71673fd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/dired/init.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ local function create_shortcut_manager()
616616
end
617617
assigned = {}
618618
pool = vim.split(Config.shortcuts, '')
619+
api.nvim_buf_clear_namespace(state.buf, ns_mark, 0, -1)
619620
end,
620621
assign = function(state, row)
621622
local key = select(1, unpack(pool))
@@ -625,6 +626,7 @@ local function create_shortcut_manager()
625626
hl_group = 'DiredShort',
626627
virt_text_pos = 'inline',
627628
virt_text = { { ('[%s] '):format(key), 'DiredShort' } },
629+
invalidate = true,
628630
})
629631
pool = { unpack(pool, 2) }
630632
vim.keymap.set('n', key, function()
@@ -693,9 +695,15 @@ Browser.State = {
693695
if next(s.shortcut_manager.get()) ~= nil then
694696
s.shortcut_manager.reset(new_state)
695697
end
698+
696699
if api.nvim_buf_is_valid(new_state.buf) then
697700
api.nvim_buf_set_lines(new_state.buf, 0, -1, false, {})
698701
api.nvim_buf_clear_namespace(new_state.buf, ns_id, 0, -1)
702+
703+
if #entries_to_show == 0 then
704+
return
705+
end
706+
699707
vim.bo[new_state.buf].modifiable = true
700708
for i, entry in ipairs(entries_to_show) do
701709
UI.Entry.render(new_state, i - 1, entry, i)
@@ -708,7 +716,6 @@ Browser.State = {
708716
new_state.shortcut_manager.assign(new_state, i - 1)
709717
end
710718

711-
local mode = api.nvim_get_mode().mode
712719
if
713720
not s.initialized
714721
and #entries_to_show <= api.nvim_win_get_height(new_state.win)
@@ -725,6 +732,7 @@ Browser.State = {
725732
virt_text_pos = 'inline',
726733
})
727734
end
735+
728736
if not s.initialized then
729737
local timer = assert(vim.uv.new_timer())
730738
-- Attach buffer for search

0 commit comments

Comments
 (0)