From fa2c92d19066201cf8f4a924b99e892363f00d64 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:06:25 +0100 Subject: [PATCH] Editor: tweak label for "Go to implementation" tabs (#8201) No release notes as this is a followup to #7890 Release Notes: - N/A --- crates/editor/src/editor.rs | 13 ++++++++++--- crates/editor/src/hover_links.rs | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 568b94ce9d..206bcc60a1 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -7409,6 +7409,7 @@ impl Editor { let definitions = definitions.await?; editor.update(&mut cx, |editor, cx| { editor.navigate_to_hover_links( + Some(kind), definitions.into_iter().map(HoverLink::Text).collect(), split, cx, @@ -7441,8 +7442,9 @@ impl Editor { .detach(); } - pub fn navigate_to_hover_links( + pub(crate) fn navigate_to_hover_links( &mut self, + kind: Option, mut definitions: Vec, split: bool, cx: &mut ViewContext, @@ -7511,13 +7513,18 @@ impl Editor { cx.spawn(|editor, mut cx| async move { let (title, location_tasks, workspace) = editor .update(&mut cx, |editor, cx| { + let tab_kind = match kind { + Some(GotoDefinitionKind::Implementation) => "Implementations", + _ => "Definitions", + }; let title = definitions .iter() .find_map(|definition| match definition { HoverLink::Text(link) => link.origin.as_ref().map(|origin| { let buffer = origin.buffer.read(cx); format!( - "Definitions for {}", + "{} for {}", + tab_kind, buffer .text_for_range(origin.range.clone()) .collect::() @@ -7526,7 +7533,7 @@ impl Editor { HoverLink::InlayHint(_, _) => None, HoverLink::Url(_) => None, }) - .unwrap_or("Definitions".to_string()); + .unwrap_or(tab_kind.to_string()); let location_tasks = definitions .into_iter() .map(|definition| match definition { diff --git a/crates/editor/src/hover_links.rs b/crates/editor/src/hover_links.rs index 5baf6e9e96..0c1fa02010 100644 --- a/crates/editor/src/hover_links.rs +++ b/crates/editor/src/hover_links.rs @@ -138,7 +138,7 @@ impl Editor { cx.focus(&self.focus_handle); } - self.navigate_to_hover_links(hovered_link_state.links, modifiers.alt, cx); + self.navigate_to_hover_links(None, hovered_link_state.links, modifiers.alt, cx); return; } }