Skip to content

Commit 8f0de11

Browse files
committed
improve bs
1 parent 8df447a commit 8f0de11

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lua/dired/init.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,12 +990,21 @@ Browser.State = {
990990
api.nvim_buf_attach(state.search_buf, false, {
991991
on_lines = function()
992992
local line = api.nvim_buf_get_text(state.search_buf, 0, 0, 0, -1, {})[1]
993+
if state.last_line and line .. SEPARATOR == state.last_line then
994+
local parent_path = vim.fs.dirname(vim.fs.normalize(state.last_line))
995+
.. SEPARATOR
996+
vim.schedule(function()
997+
Actions.openDirectory(state, parent_path).run()
998+
end)
999+
return
1000+
end
1001+
9931002
local query = line:sub(#(state.abbr_path or state.current_path) + 1)
9941003
query = query:gsub('^' .. SEPARATOR, '')
9951004

9961005
-- Empty query or directory navigation
997-
if query == '' or query:match(SEPARATOR .. '$') then
998-
Actions.openDirectory(state, vim.fs.normalize(line)).run()
1006+
if query == '' then
1007+
Actions.openDirectory(state, state.current_path).run()
9991008
return
10001009
end
10011010
state.entries = {}
@@ -1175,6 +1184,7 @@ Actions.openDirectory = function(state, path)
11751184
return F.IO.fromEffect(function()
11761185
if api.nvim_buf_is_valid(refreshed_state.search_buf) then
11771186
path = refreshed_state.abbr_path or refreshed_state.current_path
1187+
state.last_line = path
11781188
api.nvim_buf_set_lines(refreshed_state.search_buf, 0, -1, false, { path })
11791189
local end_col = api.nvim_strwidth(path)
11801190
api.nvim_win_set_cursor(refreshed_state.search_win, { 1, end_col })

0 commit comments

Comments
 (0)