Skip to content

fix: cancel previous entry if we are previewing different entry#2551

Merged
ibhagwan merged 2 commits intoibhagwan:mainfrom
phanen:async-cancellation
Feb 5, 2026
Merged

fix: cancel previous entry if we are previewing different entry#2551
ibhagwan merged 2 commits intoibhagwan:mainfrom
phanen:async-cancellation

Conversation

@phanen
Copy link
Contributor

@phanen phanen commented Feb 3, 2026

The execute order of parse_entry callback can be random when it's slow
(e.g. callback in network request)

self:debounce don't work here, because we run a async parse_entry
callback again in the debounce timer callback

@phanen
Copy link
Contributor Author

phanen commented Feb 3, 2026

Not sure if we have a way to cancel a coroutine. Maybe not possible in lua 5.1.
EDIT: oK it's not possible, can only be done with some framework https://github.com/folke/snacks.nvim/blob/01f6cac48fd7a3ec9bf7e5fc8a5ae22381861baf/lua/snacks/picker/util/async.lua#L66-L68, https://github.com/lewis6991/async.nvim/blob/0f0949cafac197c9b8f2c486fb5eb5865c0abfc3/lua/async.lua#L719-L721

@phanen phanen marked this pull request as draft February 3, 2026 12:43
@phanen phanen force-pushed the async-cancellation branch from a5c4158 to bde9241 Compare February 3, 2026 12:54
The root cause is query isn't copied to opts.__alt_opts
The execute order of parse_entry callback can be random when it's slow
(e.g. callback in network request)

self:debounce don't work here, because we run a async parse_entry
callback again in the debounce timer callback
@phanen phanen force-pushed the async-cancellation branch 3 times, most recently from bde9241 to 614d8ae Compare February 3, 2026 14:23
@phanen phanen marked this pull request as ready for review February 3, 2026 14:33
@ibhagwan
Copy link
Owner

ibhagwan commented Feb 5, 2026

Ty @phanen

@ibhagwan ibhagwan merged commit c86b72c into ibhagwan:main Feb 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants