Skip to content

fix(#1553): set correct side on vim open directory #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lua/nvim-tree/actions/node/open-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local view = require "nvim-tree.view"

local M = {}

local function get_split_cmd()
local function get_split_side()
local side = view.View.side
if side == "right" then
return "aboveleft"
Expand Down Expand Up @@ -193,13 +193,12 @@ local function open_in_new_window(filename, mode, win_ids)
return
end
local do_split = mode == "split" or mode == "vsplit"
local vertical = mode ~= "split"
local split_side = get_split_side()

-- Target is invalid or window does not exist in current tabpage: create new window
if not target_winid or not vim.tbl_contains(win_ids, target_winid) then
local split_cmd = get_split_cmd()
local splitside = view.is_vertical() and "vsp" or "sp"
vim.cmd(split_cmd .. " " .. splitside)
local split_cmd = view.is_vertical() and "vsplit" or "split"
vim.cmd(split_side .. " " .. split_cmd)
target_winid = api.nvim_get_current_win()
lib.target_winid = target_winid

Expand All @@ -218,7 +217,8 @@ local function open_in_new_window(filename, mode, win_ids)

local cmd
if do_split or #api.nvim_list_wins() == 1 then
cmd = string.format("%ssplit %s", vertical and "vertical " or "", fname)
local split_cmd = (mode ~= "split") and "vsplit" or "split"
cmd = string.format("%s %s %s", split_side, split_cmd, fname)
else
cmd = string.format("edit %s", fname)
end
Expand Down