perf: cache repo root and harden async paths
Problem: get_repo_root() shells out on every call, causing 4-6 redundant subprocesses per gdiff_file() invocation. highlight_vim_syntax() leaks a scratch buffer if nvim_buf_call errors. lib.ensure() silently drops callbacks during download, permanently missing intra-line highlights. The debounce timer callback can operate on an invalid buffer. Solution: Cache get_repo_root() results by parent directory. Wrap nvim_buf_call and nvim_buf_delete in pcall so the scratch buffer is always cleaned up. Queue pending callbacks in lib.ensure() so all callers receive the handle once the download completes. Guard the debounce timer callback with nvim_buf_is_valid.
This commit is contained in:
parent
a2053a132b
commit
3c3b27a2cb
4 changed files with 30 additions and 14 deletions
|
|
@ -200,7 +200,9 @@ local function create_debounced_highlight(bufnr)
|
|||
timer = nil
|
||||
t:close()
|
||||
end
|
||||
highlight_buffer(bufnr)
|
||||
if vim.api.nvim_buf_is_valid(bufnr) then
|
||||
highlight_buffer(bufnr)
|
||||
end
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue