editor: Add delay to trigger hover popover. (#1361)

This commit is contained in:
Jason Lee 2025-10-13 10:40:09 +08:00 committed by GitHub
parent 8a63fd67ab
commit 08cf199b39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -46,6 +46,7 @@ impl Lsp {
})
.collect()
}
pub(crate) fn update_document_colors(
&mut self,
text: &Rope,

View file

@ -1,3 +1,5 @@
use std::time::Duration;
use anyhow::Result;
use gpui::{App, Context, Task, Window};
use ropey::Rope;
@ -47,6 +49,9 @@ impl InputState {
let mut symbol_range = self.text.word_range(offset).unwrap_or(offset..offset);
let editor = cx.entity();
self.lsp._hover_task = cx.spawn_in(window, async move |_, cx| {
cx.background_executor()
.timer(Duration::from_millis(150))
.await;
let result = task.await?;
_ = editor.update(cx, |editor, cx| match result {