Skip to content

Commit

Permalink
feat(commands): add option to open top file even when nested (#1218)
Browse files Browse the repository at this point in the history
  • Loading branch information
pysan3 committed Nov 7, 2023
1 parent 76dd1b4 commit f053f09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ local config = {
},
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
-- ["<cr>"] = { "open", config = { no_expand_file = true } }, -- open top file instead of expanding when nested
["<esc>"] = "cancel", -- close preview or floating neo-tree window
["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = false } },
["l"] = "focus_preview",
Expand Down
3 changes: 2 additions & 1 deletion lua/neo-tree/sources/common/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ local open_with_cmd = function(state, open_cmd, toggle_directory, open_file)
if toggle_directory and node.type == "directory" then
toggle_directory(node)
elseif node:has_children() then
if node:is_expanded() and node.type ~= "directory" then
local no_expand_file = (state.config or {}).no_expand_file
if node.type ~= "directory" and (no_expand_file or node:is_expanded()) then
return open()
end

Expand Down

0 comments on commit f053f09

Please sign in to comment.