perf: speed up session loading (#246)

* perf: only execute on current buffer since this event is called on each buffer

* fix: only execute `SessionLoadPost` autocommand when a full session is loaded
This commit is contained in:
Micah Halter 2023-12-06 23:58:53 -08:00 committed by GitHub
parent 2c80182d75
commit b3c24f4b3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1128,13 +1128,13 @@ M.setup = function(opts)
group = aug,
pattern = "*",
callback = function(params)
if vim.g.SessionLoad ~= 1 then
return
end
local util = require("oil.util")
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
local bufname = vim.api.nvim_buf_get_name(bufnr)
local scheme = util.parse_url(bufname)
if config.adapters[scheme] and vim.api.nvim_buf_line_count(bufnr) == 1 then
load_oil_buffer(bufnr)
end
local scheme = util.parse_url(params.file)
if config.adapters[scheme] and vim.api.nvim_buf_line_count(params.buf) == 1 then
load_oil_buffer(params.buf)
end
end,
})