Skip to content

Commit 5af3cfa

Browse files
committed
fix: split if nvim-tree is the only window
also fix resize when trying to open but the buffer exists
1 parent 471afc1 commit 5af3cfa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lua/nvim-tree/actions/open-file.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function M.fn(mode, filename)
204204
end
205205

206206
local cmd
207-
if do_split then
207+
if do_split or #api.nvim_list_wins() == 1 then
208208
cmd = string.format("%ssplit ", vertical and "vertical " or "")
209209
else
210210
cmd = "edit "
@@ -213,9 +213,10 @@ function M.fn(mode, filename)
213213
cmd = cmd .. vim.fn.fnameescape(filename)
214214
api.nvim_set_current_win(target_winid)
215215
pcall(vim.cmd, cmd)
216-
if M.resize_window then
217-
view.resize()
218-
end
216+
end
217+
218+
if M.resize_window then
219+
view.resize()
219220
end
220221

221222
if mode == "preview" then

0 commit comments

Comments
 (0)