Skip to content

Commit f053f09

Browse files
authored
feat(commands): add option to open top file even when nested (#1218)
1 parent 76dd1b4 commit f053f09

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lua/neo-tree/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ local config = {
365365
},
366366
["<2-LeftMouse>"] = "open",
367367
["<cr>"] = "open",
368+
-- ["<cr>"] = { "open", config = { no_expand_file = true } }, -- open top file instead of expanding when nested
368369
["<esc>"] = "cancel", -- close preview or floating neo-tree window
369370
["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = false } },
370371
["l"] = "focus_preview",

lua/neo-tree/sources/common/commands.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ local open_with_cmd = function(state, open_cmd, toggle_directory, open_file)
713713
if toggle_directory and node.type == "directory" then
714714
toggle_directory(node)
715715
elseif node:has_children() then
716-
if node:is_expanded() and node.type ~= "directory" then
716+
local no_expand_file = (state.config or {}).no_expand_file
717+
if node.type ~= "directory" and (no_expand_file or node:is_expanded()) then
717718
return open()
718719
end
719720

0 commit comments

Comments
 (0)