From 6bb209a83414f2aad192a2aee046e6f3f17baafe Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Thu, 16 Jun 2022 00:01:15 -0400 Subject: [PATCH] fix #1215 --- lua/core/utils.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 59d771b..9cc8611 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -6,8 +6,9 @@ local merge_tb = vim.tbl_deep_extend M.close_buffer = function(force) if vim.bo.buftype == "terminal" then - api.nvim_win_hide(0) - return + force = force or #api.nvim_list_wins() < 2 and ":bd!" + local swap = force and #api.nvim_list_bufs() > 1 and ":bp | bd!" .. fn.bufnr() + return vim.cmd(swap or force or "hide") end local fileExists = fn.filereadable(fn.expand "%p") @@ -20,7 +21,6 @@ M.close_buffer = function(force) end force = force or not vim.bo.buflisted or vim.bo.buftype == "nofile" - -- if not force, change to prev buf and then close current local close_cmd = force and ":bd!" or ":bp | bd" .. fn.bufnr() vim.cmd(close_cmd)