Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make auto-signature help respect popover delay (#46745)
Muhammad Salar Khan5418c919172c
diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex 337520c7e9b..5c4157d4c44 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -48,7 +48,7 @@ use project::{};use serde_json::{self, json};use settings::{- AllLanguageSettingsContent, EditorSettingsContent, IndentGuideBackgroundColoring,+ AllLanguageSettingsContent, DelayMs, EditorSettingsContent, IndentGuideBackgroundColoring,IndentGuideColoring, InlayHintSettingsContent, ProjectSettingsContent, SearchSettingsContent,SettingsStore,};@@ -13544,6 +13544,7 @@ async fn test_handle_input_for_show_signature_help_auto_signature_help_true(cx.update_global::<SettingsStore, _>(|settings, cx| {settings.update_user_settings(cx, |settings| {settings.editor.auto_signature_help = Some(true);+ settings.editor.hover_popover_delay = Some(DelayMs(300));});});});diff --git a/crates/editor/src/signature_help.rs b/crates/editor/src/signature_help.rsindex e88ede2909b..7781b0a740b 100644--- a/crates/editor/src/signature_help.rs+++ b/crates/editor/src/signature_help.rs@@ -10,6 +10,7 @@ use markdown::{Markdown, MarkdownElement};use multi_buffer::{Anchor, MultiBufferOffset, ToOffset};use settings::Settings;use std::ops::Range;+use std::time::Duration;use text::Rope;use theme::ThemeSettings;use ui::{@@ -170,6 +171,10 @@ impl Editor {return;}+ // If there's an already running signature+ // help task, this will drop it.+ self.signature_help_state.task = None;+let position = self.selections.newest_anchor().head();let Some((buffer, buffer_position)) =self.buffer.read(cx).text_anchor_for_position(position, cx)@@ -179,14 +184,23 @@ impl Editor {let Some(lsp_store) = self.project().map(|p| p.read(cx).lsp_store()) else {return;};- let task = lsp_store.update(cx, |lsp_store, cx| {+ let lsp_task = lsp_store.update(cx, |lsp_store, cx| {lsp_store.signature_help(&buffer, buffer_position, cx)});let language = self.language_at(position, cx);+ let signature_help_delay_ms = EditorSettings::get_global(cx).hover_popover_delay.0;+self.signature_help_state.set_task(cx.spawn_in(window, async move |editor, cx| {- let signature_help = task.await;+ if signature_help_delay_ms > 0 {+ cx.background_executor()+ .timer(Duration::from_millis(signature_help_delay_ms))+ .await;+ }++ let signature_help = lsp_task.await;+editor.update(cx, |editor, cx| {let Some(mut signature_help) =