Skip to content

Commit ab8ca9f

Browse files
author
Abdullatif-k
authored
fix: choose correct split direction when Neo-tree is only window, fixes #576 (#577)
1 parent 8976195 commit ab8ca9f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/neo-tree/utils.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,15 @@ M.open_file = function(state, path, open_cmd)
489489
if is_neo_tree_window then
490490
-- Neo-tree must be the only window, restore it's status as a sidebar
491491
local width = M.get_value(state, "window.width", 40, false)
492-
result, err = pcall(vim.cmd, "vsplit " .. escaped_path)
492+
local nt = require("neo-tree")
493+
local split_command = "vsplit "
494+
-- respect window position in user config when Neo-tree is the only window
495+
if nt.config.window.position == "left" then
496+
split_command = "rightbelow vs "
497+
elseif nt.config.window.position == "right" then
498+
split_command = "leftabove vs "
499+
end
500+
result, err = pcall(vim.cmd, split_command .. escaped_path)
493501
vim.api.nvim_win_set_width(winid, width)
494502
else
495503
result, err = pcall(vim.cmd, open_cmd .. " " .. escaped_path)

0 commit comments

Comments
 (0)