Skip to content

Commit b243296

Browse files
committed
feat: support create file in search window
1 parent a27eb74 commit b243296

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lua/dired/init.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ Actions.createAndEdit = function(state, path, action)
12951295
FileOps.createFile(path).fork(reject, function()
12961296
vim.schedule(function()
12971297
api.nvim_win_close(state.win, true)
1298-
api.nvim_win_close(state.search_win, true)
1298+
-- pcall(api.nvim_win_close(state.search_win, true)
12991299
vim.cmd.stopinsert()
13001300
action(path)
13011301
resolve(state)
@@ -1360,10 +1360,18 @@ Browser.setup = function(state)
13601360
)
13611361
end
13621362
local new_path = PathOps.getSelectPath(state)
1363+
if current_buf == state.search_buf then
1364+
new_path = api.nvim_buf_get_lines(0, 0, -1, false)[1]
1365+
end
1366+
new_path = vim.fs.normalize(new_path)
13631367
if PathOps.isDirectory(new_path) then
13641368
Actions.openDirectory(state, new_path).run()
13651369
elseif PathOps.isFile(new_path) then
13661370
Actions.openFile(state, new_path, vim.cmd.edit)
1371+
elseif current_buf == state.search_buf then
1372+
Actions.createAndEdit(state, new_path, vim.cmd.edit).fork(function(err)
1373+
Notify.err(err)
1374+
end, function() end)
13671375
end
13681376
end,
13691377
buffer = { state.search_buf, state.buf },

0 commit comments

Comments
 (0)