diff options
author | HampusM <hampus@hampusmat.com> | 2024-05-31 22:15:03 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-05-31 22:15:03 +0200 |
commit | 6aefafe78fa6946d3596ba4226218b03da8dba33 (patch) | |
tree | a7543df071d894434c13990b7e67d27c608a8f88 /lua | |
parent | 47263aa9448e8802562ea079247db061be152989 (diff) |
make logic in close_current_buffer clearer
Diffstat (limited to 'lua')
-rw-r--r-- | lua/functions.lua | 8 |
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 }) |