Fix review comments
This commit is contained in:
parent
9db3f54ac3
commit
e606e2e239
3 changed files with 13 additions and 31 deletions
|
@ -1,6 +1,6 @@
|
|||
use gpui::DefiniteLength;
|
||||
use gpui::{
|
||||
FontStyle, FontWeight, HighlightStyle, SharedString, StrikethroughStyle, UnderlineStyle, px,
|
||||
DefiniteLength, FontStyle, FontWeight, HighlightStyle, SharedString, StrikethroughStyle,
|
||||
UnderlineStyle, px,
|
||||
};
|
||||
use language::HighlightId;
|
||||
use std::{fmt::Display, ops::Range, path::PathBuf};
|
||||
|
|
|
@ -938,7 +938,6 @@ mod tests {
|
|||
HighlightId, Language, LanguageConfig, LanguageMatcher, LanguageRegistry, tree_sitter_rust,
|
||||
};
|
||||
use pretty_assertions::assert_eq;
|
||||
use ui::Pixels;
|
||||
|
||||
async fn parse(input: &str) -> ParsedMarkdown {
|
||||
parse_markdown(input, None, None).await
|
||||
|
@ -1226,35 +1225,25 @@ mod tests {
|
|||
// Test pixel values
|
||||
assert_eq!(
|
||||
MarkdownParser::parse_length("100px"),
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
|
||||
100.0
|
||||
))))
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(100.0))))
|
||||
);
|
||||
assert_eq!(
|
||||
MarkdownParser::parse_length("50px"),
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
|
||||
50.0
|
||||
))))
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(50.0))))
|
||||
);
|
||||
assert_eq!(
|
||||
MarkdownParser::parse_length("0px"),
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
|
||||
0.0
|
||||
))))
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(0.0))))
|
||||
);
|
||||
|
||||
// Test values without units (should be treated as pixels)
|
||||
assert_eq!(
|
||||
MarkdownParser::parse_length("100"),
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
|
||||
100.0
|
||||
))))
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(100.0))))
|
||||
);
|
||||
assert_eq!(
|
||||
MarkdownParser::parse_length("42"),
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
|
||||
42.0
|
||||
))))
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(42.0))))
|
||||
);
|
||||
|
||||
// Test invalid values
|
||||
|
@ -1272,15 +1261,11 @@ mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
MarkdownParser::parse_length("100.25px"),
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
|
||||
100.25
|
||||
))))
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(100.25))))
|
||||
);
|
||||
assert_eq!(
|
||||
MarkdownParser::parse_length("42.0"),
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(Pixels(
|
||||
42.0
|
||||
))))
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Pixels(px(42.0))))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,6 @@ use ui::{
|
|||
};
|
||||
use workspace::{OpenOptions, OpenVisible, Workspace};
|
||||
|
||||
const OPEN_IMAGE_TOOLTIP: SharedString = SharedString::new_static("open image");
|
||||
const TOGGLE_CHECKBOX_TOOLTIP: SharedString = SharedString::new_static("toggle checkbox");
|
||||
|
||||
pub struct CheckboxClickedEvent {
|
||||
pub checked: bool,
|
||||
pub source_range: Range<usize>,
|
||||
|
@ -263,7 +260,7 @@ fn render_markdown_list_item(
|
|||
)
|
||||
.hover(|s| s.cursor_pointer())
|
||||
.tooltip(|_, cx| {
|
||||
InteractiveMarkdownElementTooltip::new(None, TOGGLE_CHECKBOX_TOOLTIP, cx).into()
|
||||
InteractiveMarkdownElementTooltip::new(None, "toggle checkbox", cx).into()
|
||||
})
|
||||
.into_any_element(),
|
||||
};
|
||||
|
@ -767,7 +764,7 @@ fn render_markdown_image(image: &Image, cx: &mut RenderContext) -> AnyElement {
|
|||
move |_, cx| {
|
||||
InteractiveMarkdownElementTooltip::new(
|
||||
Some(alt_text.clone().unwrap_or(link.to_string().into())),
|
||||
OPEN_IMAGE_TOOLTIP,
|
||||
"open image",
|
||||
cx,
|
||||
)
|
||||
.into()
|
||||
|
@ -811,14 +808,14 @@ struct InteractiveMarkdownElementTooltip {
|
|||
impl InteractiveMarkdownElementTooltip {
|
||||
pub fn new(
|
||||
tooltip_text: Option<SharedString>,
|
||||
action_text: SharedString,
|
||||
action_text: impl Into<SharedString>,
|
||||
cx: &mut App,
|
||||
) -> Entity<Self> {
|
||||
let tooltip_text = tooltip_text.map(|t| util::truncate_and_trailoff(&t, 50).into());
|
||||
|
||||
cx.new(|_cx| Self {
|
||||
tooltip_text,
|
||||
action_text,
|
||||
action_text: action_text.into(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue