ui: Remove `InlineCode` component (#45123)

Danilo Leal created

We recently added this `InlineCode` component but I'd forgotten that
many months ago I also introduced an `inline_code` method to the Label
component which does the same thing. That means we don't need a
standalone component at all!

Release Notes:

- N/A

Change summary

crates/language_models/src/provider/lmstudio.rs |  4 
crates/language_models/src/provider/ollama.rs   | 10 +-
crates/ui/src/components.rs                     |  2 
crates/ui/src/components/inline_code.rs         | 64 -------------------
4 files changed, 7 insertions(+), 73 deletions(-)

Detailed changes

crates/language_models/src/provider/lmstudio.rs 🔗

@@ -20,7 +20,7 @@ use settings::{Settings, SettingsStore};
 use std::pin::Pin;
 use std::str::FromStr;
 use std::{collections::BTreeMap, sync::Arc};
-use ui::{ButtonLike, Indicator, InlineCode, List, ListBulletItem, prelude::*};
+use ui::{ButtonLike, Indicator, List, ListBulletItem, prelude::*};
 use util::ResultExt;
 
 use crate::AllLanguageModelSettings;
@@ -691,7 +691,7 @@ impl Render for ConfigurationView {
                             .child(
                                 ListBulletItem::new("")
                                     .child(Label::new("To get your first model, try running"))
-                                    .child(InlineCode::new("lms get qwen2.5-coder-7b")),
+                                    .child(Label::new("lms get qwen2.5-coder-7b").inline_code(cx)),
                             ),
                     ),
                 )

crates/language_models/src/provider/ollama.rs 🔗

@@ -23,8 +23,8 @@ use std::sync::LazyLock;
 use std::sync::atomic::{AtomicU64, Ordering};
 use std::{collections::HashMap, sync::Arc};
 use ui::{
-    ButtonLike, ButtonLink, ConfiguredApiCard, ElevationIndex, InlineCode, List, ListBulletItem,
-    Tooltip, prelude::*,
+    ButtonLike, ButtonLink, ConfiguredApiCard, ElevationIndex, List, ListBulletItem, Tooltip,
+    prelude::*,
 };
 use ui_input::InputField;
 
@@ -724,7 +724,7 @@ impl ConfigurationView {
         cx.notify();
     }
 
-    fn render_instructions() -> Div {
+    fn render_instructions(cx: &mut Context<Self>) -> Div {
         v_flex()
             .gap_2()
             .child(Label::new(
@@ -742,7 +742,7 @@ impl ConfigurationView {
                     .child(
                         ListBulletItem::new("")
                             .child(Label::new("Start Ollama and download a model:"))
-                            .child(InlineCode::new("ollama run gpt-oss:20b")),
+                            .child(Label::new("ollama run gpt-oss:20b").inline_code(cx)),
                     )
                     .child(ListBulletItem::new(
                         "Click 'Connect' below to start using Ollama in Zed",
@@ -833,7 +833,7 @@ impl Render for ConfigurationView {
 
         v_flex()
             .gap_2()
-            .child(Self::render_instructions())
+            .child(Self::render_instructions(cx))
             .child(self.render_api_url_editor(cx))
             .child(self.render_api_key_editor(cx))
             .child(

crates/ui/src/components.rs 🔗

@@ -17,7 +17,6 @@ mod icon;
 mod image;
 mod indent_guides;
 mod indicator;
-mod inline_code;
 mod keybinding;
 mod keybinding_hint;
 mod label;
@@ -64,7 +63,6 @@ pub use icon::*;
 pub use image::*;
 pub use indent_guides::*;
 pub use indicator::*;
-pub use inline_code::*;
 pub use keybinding::*;
 pub use keybinding_hint::*;
 pub use label::*;

crates/ui/src/components/inline_code.rs 🔗

@@ -1,64 +0,0 @@
-use crate::prelude::*;
-use gpui::{AnyElement, IntoElement, ParentElement, Styled};
-
-/// InlineCode mimics the way inline code is rendered when wrapped in backticks in Markdown.
-///
-/// # Usage Example
-///
-/// ```
-/// use ui::InlineCode;
-///
-/// let InlineCode = InlineCode::new("<div>hey</div>");
-/// ```
-#[derive(IntoElement, RegisterComponent)]
-pub struct InlineCode {
-    label: SharedString,
-    label_size: LabelSize,
-}
-
-impl InlineCode {
-    pub fn new(label: impl Into<SharedString>) -> Self {
-        Self {
-            label: label.into(),
-            label_size: LabelSize::Default,
-        }
-    }
-
-    /// Sets the size of the label.
-    pub fn label_size(mut self, size: LabelSize) -> Self {
-        self.label_size = size;
-        self
-    }
-}
-
-impl RenderOnce for InlineCode {
-    fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
-        h_flex()
-            .min_w_0()
-            .px_0p5()
-            .overflow_hidden()
-            .bg(cx.theme().colors().text.opacity(0.05))
-            .child(Label::new(self.label).size(self.label_size).buffer_font(cx))
-    }
-}
-
-impl Component for InlineCode {
-    fn scope() -> ComponentScope {
-        ComponentScope::DataDisplay
-    }
-
-    fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
-        Some(
-            v_flex()
-                .gap_6()
-                .child(
-                    example_group(vec![single_example(
-                        "Simple",
-                        InlineCode::new("zed.dev").into_any_element(),
-                    )])
-                    .vertical(),
-                )
-                .into_any_element(),
-        )
-    }
-}