From c5f43ee81ccfd21f71da9bd28b968a49f3ada846 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 28 Aug 2024 18:25:07 +0300 Subject: [PATCH] Forbid signature popovers when completion menu is open (#17009) Closes https://github.com/zed-industries/zed/issues/16748 Release Notes: - Fixed signature info popovers appearing when completion menu is open --- crates/editor/src/editor_tests.rs | 32 +++++++++++++++++++++++++++++ crates/editor/src/signature_help.rs | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 4d08466bc7..1a22ab7475 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -7507,6 +7507,7 @@ async fn test_completion(cx: &mut gpui::TestAppContext) { resolve_provider: Some(true), ..Default::default() }), + signature_help_provider: Some(lsp::SignatureHelpOptions::default()), ..Default::default() }, cx, @@ -7535,6 +7536,37 @@ async fn test_completion(cx: &mut gpui::TestAppContext) { .await; assert_eq!(counter.load(atomic::Ordering::Acquire), 1); + let _handler = handle_signature_help_request( + &mut cx, + lsp::SignatureHelp { + signatures: vec![lsp::SignatureInformation { + label: "test signature".to_string(), + documentation: None, + parameters: Some(vec![lsp::ParameterInformation { + label: lsp::ParameterLabel::Simple("foo: u8".to_string()), + documentation: None, + }]), + active_parameter: None, + }], + active_signature: None, + active_parameter: None, + }, + ); + cx.update_editor(|editor, cx| { + assert!( + !editor.signature_help_state.is_shown(), + "No signature help was called for" + ); + editor.show_signature_help(&ShowSignatureHelp, cx); + }); + cx.run_until_parked(); + cx.update_editor(|editor, _| { + assert!( + !editor.signature_help_state.is_shown(), + "No signature help should be shown when completions menu is open" + ); + }); + let apply_additional_edits = cx.update_editor(|editor, cx| { editor.context_menu_next(&Default::default(), cx); editor diff --git a/crates/editor/src/signature_help.rs b/crates/editor/src/signature_help.rs index 9a19e0e0fd..5b1d9ab1b3 100644 --- a/crates/editor/src/signature_help.rs +++ b/crates/editor/src/signature_help.rs @@ -149,7 +149,7 @@ impl Editor { } pub fn show_signature_help(&mut self, _: &ShowSignatureHelp, cx: &mut ViewContext) { - if self.pending_rename.is_some() { + if self.pending_rename.is_some() || self.has_active_completions_menu() { return; }