mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
cancel salsa's validation
This small fix should improve rust-analyzer resopnsivness for real-time operations like onEnter handling. Turns out, salsa's validation can take hundreds of milliseconds, and, in case no changes were made, it won't be triggering any queries. Because we check for cancellation in queries, that means that validation is not cancellable! What this PR does is injecting check_canceled checks into validation, by using salsa's event API, which wasn't meant to be used like this, but, hey, it works! Here's the onEnter handling before and after this change: https://youtu.be/7-ffPzgvH7o
This commit is contained in:
parent
8c3cd8f121
commit
0ee5bd16c9
1 changed files with 5 additions and 0 deletions
|
@ -31,6 +31,11 @@ impl salsa::Database for RootDatabase {
|
|||
fn on_propagated_panic(&self) -> ! {
|
||||
Canceled::throw()
|
||||
}
|
||||
fn salsa_event(&self, event: impl Fn() -> salsa::Event<RootDatabase>) {
|
||||
if let salsa::EventKind::DidValidateMemoizedValue { .. } = event().kind {
|
||||
self.check_canceled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for RootDatabase {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue