Skip to content

fix(#1564): reset &bufhidden when opening an existing (maybe previewed) buffer #1572

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions lua/nvim-tree/actions/node/open-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
local api = vim.api

local lib = require "nvim-tree.lib"
local log = require "nvim-tree.log"
local utils = require "nvim-tree.utils"
local view = require "nvim-tree.view"

Expand Down Expand Up @@ -146,6 +147,7 @@ local function open_file_in_tab(filename)
end

local function on_preview(buf_loaded)
log.line("dev", "on_preview buf_loaded=%s", tostring(buf_loaded))
if not buf_loaded then
vim.bo.bufhidden = "delete"

Expand Down Expand Up @@ -243,6 +245,7 @@ local function edit_in_current_buf(filename)
end

function M.fn(mode, filename)
log.line("dev", "open-file mode=%s filename='%s'", mode, filename)
if mode == "tabnew" then
return open_file_in_tab(filename)
end
Expand All @@ -256,14 +259,19 @@ function M.fn(mode, filename)
local buf_loaded = is_already_loaded(filename)

local found_win = utils.get_win_buf_from_path(filename)
log.line("dev", "open-file found_win=%s", tostring(found_win))
if found_win and mode == "preview" then
log.line("dev", "existing preview")
return
end

if not found_win then
log.line("dev", "open-file open new win")
open_in_new_window(filename, mode, win_ids)
else
log.line("dev", "open-file set current win")
api.nvim_set_current_win(found_win)
vim.bo.bufhidden = ""
end

if M.resize_window then
Expand Down