Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Global search in a background thread #1543
Global search in a background thread #1543
Changes from all commits
bee2cb9
81d7393
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
You want to use
tokio::sync::oneshot::channel
insteadThere 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.
regex is sent from the callback of
Prompt
(move |_view, _doc, regex, event| { ... regex_sx.send() ...}
), hence capturingregex_sx
, I have just discovered thatoneshot::Sender
does not implementCopy
trait and compiler would refuse to compile here.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.
You can use a
move
closure to move it into the callbackThere 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 have this error:
I think the compiler cannot guarantee that we would call
regex_sx
only once, so it refuse to compile here.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.
Right, using a channel seems like a hack to me anyway. I'd rather pass
cx
through the regex_prompt callback as a first parameter and manually calllet (doc, view) = current!(cx)
. Then you can create the search picker instance inside the callback.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 think having a dedicated
FnOnce
callback forPromptEvent::Validate
might clear things up a bit and we can useoneshot
channel, but I really don't want to introduce any breaking change to the API, hence the hack.About passing
cx
throughregex_prompt
, wouldn't it mess up the lifetime ofcx
because we still need toawait
the search results (just my naive thought)?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.
If you use oneshot then the sender isn't async and you don't need to
block_on
here.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.
Why is this using a channel rather than creating the picker and the
global_search_task
here? Is it because you have no access tocx
oreditor
?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'll check these out and work on improvements as soon as I can (a bit occupied at the moment:) )
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.
You probably want
cx.jobs.spawn(future);
That way you're not returning an empty
job::Callback
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.
Sorry it took so long but I'm confused here; With
job::Callback
I have access toEditor
andCompositor
so I canset_status
or push the picker to the compositor. How should I accessEditor
andCompositor
if I'm usingcx.jobs.spawn(future);
, perhaps I misunderstand howjobs
and everything work here?