@@ -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));
});
});
});
@@ -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) =