Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use InlayHint instead of Inlay where appropriate
Kirill Bulatovf9131f657efa
diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rsindex 2224ecb8383..a03e2ff16fc 100644--- a/crates/collab/src/tests/integration_tests.rs+++ b/crates/collab/src/tests/integration_tests.rs@@ -7867,7 +7867,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(.insert_tree("/a",json!({- "main.rs": "fn main() { a } // and some long comment to ensure inlays are not trimmed out",+ "main.rs": "fn main() { a } // and some long comment to ensure inlay hints are not trimmed out","other.rs": "// Test file",}),)@@ -8177,7 +8177,7 @@ async fn test_inlay_hint_refresh_is_forwarded(.insert_tree("/a",json!({- "main.rs": "fn main() { a } // and some long comment to ensure inlays are not trimmed out",+ "main.rs": "fn main() { a } // and some long comment to ensure inlay hints are not trimmed out","other.rs": "// Test file",}),)diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex ef02cee3d03..904e77c9f0f 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -302,7 +302,7 @@ actions!(Hover,Format,ToggleSoftWrap,- ToggleInlays,+ ToggleInlayHints,RevealInFinder,CopyPath,CopyRelativePath,@@ -447,7 +447,7 @@ pub fn init(cx: &mut AppContext) {cx.add_action(Editor::toggle_code_actions);cx.add_action(Editor::open_excerpts);cx.add_action(Editor::toggle_soft_wrap);- cx.add_action(Editor::toggle_inlays);+ cx.add_action(Editor::toggle_inlay_hints);cx.add_action(Editor::reveal_in_finder);cx.add_action(Editor::copy_path);cx.add_action(Editor::copy_relative_path);@@ -1239,7 +1239,7 @@ enum GotoDefinitionKind {}#[derive(Debug, Clone)]-enum InlayRefreshReason {+enum InlayHintRefreshReason {Toggle(bool),SettingsChange(InlayHintSettings),NewLinesShown,@@ -1357,8 +1357,8 @@ impl Editor {}));}project_subscriptions.push(cx.subscribe(project, |editor, _, event, cx| {- if let project::Event::RefreshInlays = event {- editor.refresh_inlays(InlayRefreshReason::RefreshRequested, cx);+ if let project::Event::RefreshInlayHints = event {+ editor.refresh_inlay_hints(InlayHintRefreshReason::RefreshRequested, cx);};}));}@@ -2672,24 +2672,24 @@ impl Editor {}}- pub fn toggle_inlays(&mut self, _: &ToggleInlays, cx: &mut ViewContext<Self>) {- self.refresh_inlays(- InlayRefreshReason::Toggle(!self.inlay_hint_cache.enabled),+ pub fn toggle_inlay_hints(&mut self, _: &ToggleInlayHints, cx: &mut ViewContext<Self>) {+ self.refresh_inlay_hints(+ InlayHintRefreshReason::Toggle(!self.inlay_hint_cache.enabled),cx,);}- pub fn inlays_enabled(&self) -> bool {+ pub fn inlay_hints_enabled(&self) -> bool {self.inlay_hint_cache.enabled}- fn refresh_inlays(&mut self, reason: InlayRefreshReason, cx: &mut ViewContext<Self>) {+ fn refresh_inlay_hints(&mut self, reason: InlayHintRefreshReason, cx: &mut ViewContext<Self>) {if self.project.is_none() || self.mode != EditorMode::Full {return;}let (invalidate_cache, required_languages) = match reason {- InlayRefreshReason::Toggle(enabled) => {+ InlayHintRefreshReason::Toggle(enabled) => {self.inlay_hint_cache.enabled = enabled;if enabled {(InvalidationStrategy::RefreshRequested, None)@@ -2706,7 +2706,7 @@ impl Editor {return;}}- InlayRefreshReason::SettingsChange(new_settings) => {+ InlayHintRefreshReason::SettingsChange(new_settings) => {match self.inlay_hint_cache.update_settings(&self.buffer,new_settings,@@ -2724,11 +2724,13 @@ impl Editor {ControlFlow::Continue(()) => (InvalidationStrategy::RefreshRequested, None),}}- InlayRefreshReason::NewLinesShown => (InvalidationStrategy::None, None),- InlayRefreshReason::BufferEdited(buffer_languages) => {+ InlayHintRefreshReason::NewLinesShown => (InvalidationStrategy::None, None),+ InlayHintRefreshReason::BufferEdited(buffer_languages) => {(InvalidationStrategy::BufferEdited, Some(buffer_languages))}- InlayRefreshReason::RefreshRequested => (InvalidationStrategy::RefreshRequested, None),+ InlayHintRefreshReason::RefreshRequested => {+ (InvalidationStrategy::RefreshRequested, None)+ }};if let Some(InlaySplice {@@ -7728,8 +7730,8 @@ impl Editor {.cloned().collect::<HashSet<_>>();if !languages_affected.is_empty() {- self.refresh_inlays(- InlayRefreshReason::BufferEdited(languages_affected),+ self.refresh_inlay_hints(+ InlayHintRefreshReason::BufferEdited(languages_affected),cx,);}@@ -7767,8 +7769,8 @@ impl Editor {fn settings_changed(&mut self, cx: &mut ViewContext<Self>) {self.refresh_copilot_suggestions(true, cx);- self.refresh_inlays(- InlayRefreshReason::SettingsChange(inlay_hint_settings(+ self.refresh_inlay_hints(+ InlayHintRefreshReason::SettingsChange(inlay_hint_settings(self.selections.newest_anchor().head(),&self.buffer.read(cx).snapshot(cx),cx,diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rsindex 4c998c3afa6..b5ccdb4f2d9 100644--- a/crates/editor/src/inlay_hint_cache.rs+++ b/crates/editor/src/inlay_hint_cache.rs@@ -2684,7 +2684,7 @@ all hints should be invalidated and requeried for all of its visible excerpts"}#[gpui::test]- async fn test_toggle_inlays(cx: &mut gpui::TestAppContext) {+ async fn test_toggle_inlay_hints(cx: &mut gpui::TestAppContext) {init_test(cx, |settings| {settings.defaults.inlay_hints = Some(InlayHintSettings {enabled: false,@@ -2697,7 +2697,7 @@ all hints should be invalidated and requeried for all of its visible excerpts"let (file_with_hints, editor, fake_server) = prepare_test_objects(cx).await;editor.update(cx, |editor, cx| {- editor.toggle_inlays(&crate::ToggleInlays, cx)+ editor.toggle_inlay_hints(&crate::ToggleInlayHints, cx)});cx.foreground().start_waiting();let lsp_request_count = Arc::new(AtomicU32::new(0));@@ -2743,7 +2743,7 @@ all hints should be invalidated and requeried for all of its visible excerpts"});editor.update(cx, |editor, cx| {- editor.toggle_inlays(&crate::ToggleInlays, cx)+ editor.toggle_inlay_hints(&crate::ToggleInlayHints, cx)});cx.foreground().run_until_parked();editor.update(cx, |editor, cx| {@@ -2776,7 +2776,7 @@ all hints should be invalidated and requeried for all of its visible excerpts"});editor.update(cx, |editor, cx| {- editor.toggle_inlays(&crate::ToggleInlays, cx)+ editor.toggle_inlay_hints(&crate::ToggleInlayHints, cx)});cx.foreground().run_until_parked();editor.update(cx, |editor, cx| {@@ -2789,7 +2789,7 @@ all hints should be invalidated and requeried for all of its visible excerpts"});editor.update(cx, |editor, cx| {- editor.toggle_inlays(&crate::ToggleInlays, cx)+ editor.toggle_inlay_hints(&crate::ToggleInlayHints, cx)});cx.foreground().run_until_parked();editor.update(cx, |editor, cx| {diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rsindex 1f3adaf477f..f5edb00d589 100644--- a/crates/editor/src/scroll.rs+++ b/crates/editor/src/scroll.rs@@ -19,7 +19,7 @@ use crate::{display_map::{DisplaySnapshot, ToDisplayPoint},hover_popover::hide_hover,persistence::DB,- Anchor, DisplayPoint, Editor, EditorMode, Event, InlayRefreshReason, MultiBufferSnapshot,+ Anchor, DisplayPoint, Editor, EditorMode, Event, InlayHintRefreshReason, MultiBufferSnapshot,ToPoint,};@@ -301,7 +301,7 @@ impl Editor {cx.spawn(|editor, mut cx| async move {editor.update(&mut cx, |editor, cx| {- editor.refresh_inlays(InlayRefreshReason::NewLinesShown, cx)+ editor.refresh_inlay_hints(InlayHintRefreshReason::NewLinesShown, cx)}).ok()})@@ -333,7 +333,7 @@ impl Editor {cx,);- self.refresh_inlays(InlayRefreshReason::NewLinesShown, cx);+ self.refresh_inlay_hints(InlayHintRefreshReason::NewLinesShown, cx);}pub fn scroll_position(&self, cx: &mut ViewContext<Self>) -> Vector2F {diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex 1aa2a2dd40c..933f2597009 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -282,7 +282,7 @@ pub enum Event {new_peer_id: proto::PeerId,},CollaboratorLeft(proto::PeerId),- RefreshInlays,+ RefreshInlayHints,}pub enum LanguageServerState {@@ -2872,7 +2872,7 @@ impl Project {.upgrade(&cx).ok_or_else(|| anyhow!("project dropped"))?;this.update(&mut cx, |project, cx| {- cx.emit(Event::RefreshInlays);+ cx.emit(Event::RefreshInlayHints);project.remote_id().map(|project_id| {project.client.send(proto::RefreshInlayHints { project_id })})@@ -3436,7 +3436,7 @@ impl Project {cx: &mut ModelContext<Self>,) {if let Some(status) = self.language_server_statuses.get_mut(&language_server_id) {- cx.emit(Event::RefreshInlays);+ cx.emit(Event::RefreshInlayHints);status.pending_work.remove(&token);cx.notify();}@@ -6810,7 +6810,7 @@ impl Project {mut cx: AsyncAppContext,) -> Result<proto::Ack> {this.update(&mut cx, |_, cx| {- cx.emit(Event::RefreshInlays);+ cx.emit(Event::RefreshInlayHints);});Ok(proto::Ack {})}diff --git a/crates/quick_action_bar/src/quick_action_bar.rs b/crates/quick_action_bar/src/quick_action_bar.rsindex b506f8dc17c..a2bddff3139 100644--- a/crates/quick_action_bar/src/quick_action_bar.rs+++ b/crates/quick_action_bar/src/quick_action_bar.rs@@ -11,7 +11,7 @@ use workspace::{item::ItemHandle, ToolbarItemLocation, ToolbarItemView};pub struct QuickActionBar {buffer_search_bar: ViewHandle<BufferSearchBar>,active_item: Option<Box<dyn ItemHandle>>,- _inlays_enabled_subscription: Option<Subscription>,+ _inlay_hints_enabled_subscription: Option<Subscription>,}impl QuickActionBar {@@ -19,7 +19,7 @@ impl QuickActionBar {Self {buffer_search_bar,active_item: None,- _inlays_enabled_subscription: None,+ _inlay_hints_enabled_subscription: None,}}@@ -42,17 +42,20 @@ impl View for QuickActionBar {fn render(&mut self, cx: &mut gpui::ViewContext<'_, '_, Self>) -> gpui::AnyElement<Self> {let Some(editor) = self.active_editor() else { return Empty::new().into_any(); };- let inlays_enabled = editor.read(cx).inlays_enabled();+ let inlay_hints_enabled = editor.read(cx).inlay_hints_enabled();let mut bar = Flex::row().with_child(render_quick_action_bar_button(0,"icons/hamburger_15.svg",- inlays_enabled,- ("Inlays".to_string(), Some(Box::new(editor::ToggleInlays))),+ inlay_hints_enabled,+ (+ "Inlay hints".to_string(),+ Some(Box::new(editor::ToggleInlayHints)),+ ),cx,|this, cx| {if let Some(editor) = this.active_editor() {editor.update(cx, |editor, cx| {- editor.toggle_inlays(&editor::ToggleInlays, cx);+ editor.toggle_inlay_hints(&editor::ToggleInlayHints, cx);});}},@@ -135,15 +138,15 @@ impl ToolbarItemView for QuickActionBar {match active_pane_item {Some(active_item) => {self.active_item = Some(active_item.boxed_clone());- self._inlays_enabled_subscription.take();+ self._inlay_hints_enabled_subscription.take();if let Some(editor) = active_item.downcast::<Editor>() {- let mut inlays_enabled = editor.read(cx).inlays_enabled();- self._inlays_enabled_subscription =+ let mut inlay_hints_enabled = editor.read(cx).inlay_hints_enabled();+ self._inlay_hints_enabled_subscription =Some(cx.observe(&editor, move |_, editor, cx| {- let new_inlays_enabled = editor.read(cx).inlays_enabled();- if inlays_enabled != new_inlays_enabled {- inlays_enabled = new_inlays_enabled;+ let new_inlay_hints_enabled = editor.read(cx).inlay_hints_enabled();+ if inlay_hints_enabled != new_inlay_hints_enabled {+ inlay_hints_enabled = new_inlay_hints_enabled;cx.notify();}}));