perf: async parallel cache initialization and remove deepcopy (#6)
Some checks failed
quality / changes (push) Has been cancelled
test / Test (Neovim nightly) (push) Has been cancelled
test / Test (Neovim stable) (push) Has been cancelled
luarocks / quality (push) Has been cancelled
quality / Lua Format Check (push) Has been cancelled
quality / Lua Lint Check (push) Has been cancelled
quality / Lua Type Check (push) Has been cancelled
quality / Markdown Format Check (push) Has been cancelled
luarocks / publish (push) Has been cancelled
Some checks failed
quality / changes (push) Has been cancelled
test / Test (Neovim nightly) (push) Has been cancelled
test / Test (Neovim stable) (push) Has been cancelled
luarocks / quality (push) Has been cancelled
quality / Lua Format Check (push) Has been cancelled
quality / Lua Lint Check (push) Has been cancelled
quality / Lua Type Check (push) Has been cancelled
quality / Markdown Format Check (push) Has been cancelled
luarocks / publish (push) Has been cancelled
Problem: first completion request blocked the UI with three sequential synchronous vim.system():wait() calls (man page, command names, command list), and every subsequent completion unnecessarily deep-copied the entire cache. Solution: run all three system calls concurrently via vim.system callbacks, merging results when all complete. Queue pending completion requests during loading. Return cached items directly instead of deep-copying.
This commit is contained in:
parent
7003996643
commit
c0c59d1e57
2 changed files with 79 additions and 37 deletions
|
|
@ -26,37 +26,38 @@ local MAN_PAGE = table.concat({
|
|||
}, '\n')
|
||||
|
||||
local function mock_system()
|
||||
local original = vim.system
|
||||
local original_system = vim.system
|
||||
local original_schedule = vim.schedule
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
vim.system = function(cmd)
|
||||
vim.system = function(cmd, _, on_exit)
|
||||
local result
|
||||
if cmd[1] == 'bash' then
|
||||
return {
|
||||
wait = function()
|
||||
return { stdout = MAN_PAGE, code = 0 }
|
||||
end,
|
||||
}
|
||||
result = { stdout = MAN_PAGE, code = 0 }
|
||||
elseif cmd[1] == 'tmux' and cmd[2] == 'list-commands' then
|
||||
if cmd[3] == '-F' then
|
||||
return {
|
||||
wait = function()
|
||||
return { stdout = TMUX_NAMES, code = 0 }
|
||||
end,
|
||||
}
|
||||
result = { stdout = TMUX_NAMES, code = 0 }
|
||||
else
|
||||
result = { stdout = TMUX_COMMANDS, code = 0 }
|
||||
end
|
||||
return {
|
||||
wait = function()
|
||||
return { stdout = TMUX_COMMANDS, code = 0 }
|
||||
end,
|
||||
}
|
||||
else
|
||||
result = { stdout = '', code = 1 }
|
||||
end
|
||||
if on_exit then
|
||||
on_exit(result)
|
||||
return {}
|
||||
end
|
||||
return {
|
||||
wait = function()
|
||||
return { stdout = '', code = 1 }
|
||||
return result
|
||||
end,
|
||||
}
|
||||
end
|
||||
vim.schedule = function(fn)
|
||||
fn()
|
||||
end
|
||||
return function()
|
||||
vim.system = original
|
||||
vim.system = original_system
|
||||
vim.schedule = original_schedule
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue