summaryrefslogtreecommitdiff
path: root/lua/functions.lua
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-05-31 22:15:03 +0200
committerHampusM <hampus@hampusmat.com>2024-05-31 22:15:03 +0200
commit6aefafe78fa6946d3596ba4226218b03da8dba33 (patch)
treea7543df071d894434c13990b7e67d27c608a8f88 /lua/functions.lua
parent47263aa9448e8802562ea079247db061be152989 (diff)
make logic in close_current_buffer clearer
Diffstat (limited to 'lua/functions.lua')
-rw-r--r--lua/functions.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/lua/functions.lua b/lua/functions.lua
index 6ec4658..7d95ac3 100644
--- a/lua/functions.lua
+++ b/lua/functions.lua
@@ -110,7 +110,7 @@ function _G.close_current_buffer()
local all_buffers = vim.fn.getbufinfo()
- local buffers = table.filter(
+ local file_buffers = table.filter(
all_buffers,
function(buf_info)
return buf_info.loaded == 1
@@ -121,10 +121,10 @@ function _G.close_current_buffer()
end
)
- if #buffers ~= 0 then
- vim.cmd("buffer " .. buffers[1].bufnr)
- else
+ if #file_buffers == 0 then
vim.cmd("new")
+ else
+ vim.cmd("buffer " .. file_buffers[1].bufnr)
end
vim.api.nvim_buf_delete(current_buf_nr, { force = true })