editor: Improve hover popover delay. (#1389)

This commit is contained in:
Jason Lee 2025-10-17 10:14:20 +08:00 committed by GitHub
parent e0c1f91ed4
commit 31db24b689
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,10 +48,14 @@ impl InputState {
let task = provider.hover(&self.text, offset, window, cx); let task = provider.hover(&self.text, offset, window, cx);
let mut symbol_range = self.text.word_range(offset).unwrap_or(offset..offset); let mut symbol_range = self.text.word_range(offset).unwrap_or(offset..offset);
let editor = cx.entity(); let editor = cx.entity();
let should_delay = self.hover_popover.is_none();
self.lsp._hover_task = cx.spawn_in(window, async move |_, cx| { self.lsp._hover_task = cx.spawn_in(window, async move |_, cx| {
cx.background_executor() if should_delay {
.timer(Duration::from_millis(150)) cx.background_executor()
.await; .timer(Duration::from_millis(150))
.await;
}
let result = task.await?; let result = task.await?;
_ = editor.update(cx, |editor, cx| match result { _ = editor.update(cx, |editor, cx| match result {