fix(compiler): guard active entry before clearing in process callback
Problem: when M.compile() is called while a previous process is still running, the old process's vim.schedule_wrap callback unconditionally sets active[bufnr] = nil, wiping the new process from the tracking table. status() incorrectly returns idle and stop() becomes a no-op against the still-running process. Solution: capture obj as an upvalue in each callback and only clear active[bufnr] if it still points to the same process object.
This commit is contained in:
parent
e661ea78e8
commit
4b1f95064f
1 changed files with 6 additions and 2 deletions
|
|
@ -98,7 +98,9 @@ function M.compile(bufnr, name, provider, ctx)
|
|||
env = provider.env,
|
||||
},
|
||||
vim.schedule_wrap(function(result)
|
||||
active[bufnr] = nil
|
||||
if active[bufnr] and active[bufnr].obj == obj then
|
||||
active[bufnr] = nil
|
||||
end
|
||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||
return
|
||||
end
|
||||
|
|
@ -187,7 +189,9 @@ function M.compile(bufnr, name, provider, ctx)
|
|||
env = provider.env,
|
||||
},
|
||||
vim.schedule_wrap(function(result)
|
||||
active[bufnr] = nil
|
||||
if active[bufnr] and active[bufnr].obj == obj then
|
||||
active[bufnr] = nil
|
||||
end
|
||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||
return
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue