From 5acce153d31c821dcc3535f1cd2da2ddbd4200f7 Mon Sep 17 00:00:00 2001 From: Mika Vilpas Date: Wed, 5 Jun 2024 21:04:43 +0300 Subject: [PATCH] perf: processing open buffers only processes normal buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Buffers are processed when renaming, deleting, and trashing files in yazi. Previously all open buffers were processed, but now only normal buffers are. This actually doesn't have a big impact on performance. I just wanted to have a `perf` commit in the history 😄. Perhaps in big projects it might be noticeable, or if some future feature will require more performance. --- lua/yazi/utils.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/yazi/utils.lua b/lua/yazi/utils.lua index 66a46ade..f6ca7e93 100644 --- a/lua/yazi/utils.lua +++ b/lua/yazi/utils.lua @@ -157,7 +157,10 @@ function M.get_open_buffers() local open_buffers = {} for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do local path = vim.api.nvim_buf_get_name(bufnr) - if path ~= '' and path ~= nil then + local type = vim.api.nvim_get_option_value('buftype', { buf = bufnr }) + + local is_ordinary_file = path ~= '' and type == '' + if is_ordinary_file then local renameable_buffer = RenameableBuffer.new(bufnr, path) open_buffers[#open_buffers + 1] = renameable_buffer end