-
-
Notifications
You must be signed in to change notification settings - Fork 628
fix(diagnostics): throttle sequential CocDiagnostics updates, make debouncer safe and sequential #1430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
---@param context string identifies the callback to debounce | ||
---@param timeout number ms to wait | ||
---@param callback function to execute on completion | ||
function M.debounce(context, timeout, callback) | ||
if M.debouncers[context] then | ||
pcall(uv.close, M.debouncers[context]) | ||
-- all execution here is done in a synchronous context; no thread safety required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested exhaustively using vim.is_thread()
M.debouncers[context] = nil | ||
local timer = uv.new_timer() | ||
debouncer.timer = timer | ||
timer:start(timeout, 0, function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the key change: perform all our control operations in the direct callback instead of during scheduled execution.
timer:stop() | ||
end | ||
if not timer:is_closing() then | ||
timer:close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual reference count handling was not necessary; libuv will clear the last reference on handle close.
@@ -138,10 +138,6 @@ function M.load_project_status(cwd) | |||
reload_tree_at(opts.project_root) | |||
end) | |||
end, | |||
on_event0 = function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must have left this in when testing.
@@ -888,6 +894,10 @@ Configuration for diagnostic logging. | |||
File copy and paste actions. | |||
Type: `boolean`, Default: `false` | |||
|
|||
*nvim-tree.log.types.dev* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep needing a "clean" log context that doesn't get removed by validate_options
. Feel free to remove.
closes #1317
This took way too long...
2 could be optional, however it suits all our current use cases including git "threads". We can add an option later if we need it.
Tested:
rm .git/touched* builddefs/touched* docs/touched* ; for i in $(seq 1 200); do touch .git/touched$i; touch builddefs/touched$i; touch docs/touched$i; done
Did not test LSP; COC testing should be sufficient.