Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Feb 9, 2025
1 parent a7aa088 commit e9b65c3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lua/dired/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,13 @@ Browser.setup = function(state)
local current = state.current_path
local search_path = PathOps.getSearchPath(state)
local new_path = vim.fs.joinpath(current, name)
local pos = api.nvim_win_get_cursor(state.win)

if not PathOps.isDirectory(search_path) and not PathOps.isFile(search_path) then
if
not PathOps.isDirectory(search_path)
and not PathOps.isFile(search_path)
and pos[1] ~= 3 -- no result
then
Actions.createAndEdit(state, search_path).fork(function(err)
Notify.err(err)
end, function() end)
Expand Down Expand Up @@ -1029,6 +1034,19 @@ Browser.setup = function(state)
nmap(map)
end)

vim.keymap.set('i', '<BS>', function()
local search_line = PathOps.getSearchPath(state)
local prev_char = search_line:sub(#search_line, #search_line)
if prev_char == SEPARATOR then
state.current_path = vim.fs.dirname(state.current_path:gsub(SEPARATOR .. '$', ''))
.. SEPARATOR
Browser.refresh(state, state.current_path).run()
vim.fn.prompt_setprompt(state.search_buf, state.current_path)
return '<NL>'
end
return '<BS>'
end, { buffer = state.search_buf, expr = true })

return state
end)
end
Expand Down

0 comments on commit e9b65c3

Please sign in to comment.