Skip to content

Commit 0b83442

Browse files
committed
Fix review comments
1 parent 9db3f54 commit 0b83442

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

crates/markdown_preview/src/markdown_parser.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ mod tests {
938938
HighlightId, Language, LanguageConfig, LanguageMatcher, LanguageRegistry, tree_sitter_rust,
939939
};
940940
use pretty_assertions::assert_eq;
941-
use ui::Pixels;
942941

943942
async fn parse(input: &str) -> ParsedMarkdown {
944943
parse_markdown(input, None, None).await
@@ -1226,35 +1225,25 @@ mod tests {
12261225
// Test pixel values
12271226
assert_eq!(
12281227
MarkdownParser::parse_length("100px"),
1229-
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
1230-
100.0
1231-
))))
1228+
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(100.0))))
12321229
);
12331230
assert_eq!(
12341231
MarkdownParser::parse_length("50px"),
1235-
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
1236-
50.0
1237-
))))
1232+
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(50.0))))
12381233
);
12391234
assert_eq!(
12401235
MarkdownParser::parse_length("0px"),
1241-
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
1242-
0.0
1243-
))))
1236+
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(0.0))))
12441237
);
12451238

12461239
// Test values without units (should be treated as pixels)
12471240
assert_eq!(
12481241
MarkdownParser::parse_length("100"),
1249-
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
1250-
100.0
1251-
))))
1242+
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(100.0))))
12521243
);
12531244
assert_eq!(
12541245
MarkdownParser::parse_length("42"),
1255-
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
1256-
42.0
1257-
))))
1246+
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(42.0))))
12581247
);
12591248

12601249
// Test invalid values
@@ -1272,15 +1261,11 @@ mod tests {
12721261
);
12731262
assert_eq!(
12741263
MarkdownParser::parse_length("100.25px"),
1275-
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
1276-
100.25
1277-
))))
1264+
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(100.25))))
12781265
);
12791266
assert_eq!(
12801267
MarkdownParser::parse_length("42.0"),
1281-
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
1282-
42.0
1283-
))))
1268+
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(42.0))))
12841269
);
12851270
}
12861271

crates/markdown_preview/src/markdown_renderer.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ use ui::{
2626
};
2727
use workspace::{OpenOptions, OpenVisible, Workspace};
2828

29-
const OPEN_IMAGE_TOOLTIP: SharedString = SharedString::new_static("open image");
30-
const TOGGLE_CHECKBOX_TOOLTIP: SharedString = SharedString::new_static("toggle checkbox");
31-
3229
pub struct CheckboxClickedEvent {
3330
pub checked: bool,
3431
pub source_range: Range<usize>,
@@ -263,7 +260,7 @@ fn render_markdown_list_item(
263260
)
264261
.hover(|s| s.cursor_pointer())
265262
.tooltip(|_, cx| {
266-
InteractiveMarkdownElementTooltip::new(None, TOGGLE_CHECKBOX_TOOLTIP, cx).into()
263+
InteractiveMarkdownElementTooltip::new(None, "toggle checkbox", cx).into()
267264
})
268265
.into_any_element(),
269266
};
@@ -767,7 +764,7 @@ fn render_markdown_image(image: &Image, cx: &mut RenderContext) -> AnyElement {
767764
move |_, cx| {
768765
InteractiveMarkdownElementTooltip::new(
769766
Some(alt_text.clone().unwrap_or(link.to_string().into())),
770-
OPEN_IMAGE_TOOLTIP,
767+
"open image",
771768
cx,
772769
)
773770
.into()
@@ -811,14 +808,14 @@ struct InteractiveMarkdownElementTooltip {
811808
impl InteractiveMarkdownElementTooltip {
812809
pub fn new(
813810
tooltip_text: Option<SharedString>,
814-
action_text: SharedString,
811+
action_text: impl Into<SharedString>,
815812
cx: &mut App,
816813
) -> Entity<Self> {
817814
let tooltip_text = tooltip_text.map(|t| util::truncate_and_trailoff(&t, 50).into());
818815

819816
cx.new(|_cx| Self {
820817
tooltip_text,
821-
action_text,
818+
action_text: action_text.into(),
822819
})
823820
}
824821
}

0 commit comments

Comments
 (0)