fix: rich text link handling
This commit is contained in:
@@ -229,18 +229,30 @@ impl MarkdownText {
|
||||
|
||||
let (description, src) =
|
||||
if cursor.node().kind_id() == MARKDOWN_KIND_ID_LINK_DESTINATION {
|
||||
let node = cursor.node();
|
||||
let src = &content[node_range!()];
|
||||
let src = cursor
|
||||
.node()
|
||||
.utf8_text(content.as_ref())
|
||||
.ok()
|
||||
.unwrap_or_default();
|
||||
(src, src)
|
||||
} else {
|
||||
let node = cursor.node();
|
||||
let description = &content[node_range!()];
|
||||
let description = cursor
|
||||
.node()
|
||||
.utf8_text(content.as_ref())
|
||||
.ok()
|
||||
.unwrap_or_default();
|
||||
if cursor.goto_next_sibling() {
|
||||
debug_assert!(
|
||||
cursor.node().kind_id() == MARKDOWN_KIND_ID_LINK_DESTINATION
|
||||
);
|
||||
let node = cursor.node();
|
||||
(description, &content[node_range!()])
|
||||
(
|
||||
description,
|
||||
cursor
|
||||
.node()
|
||||
.utf8_text(content.as_ref())
|
||||
.ok()
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
} else {
|
||||
// no src for this link node
|
||||
(description, "")
|
||||
@@ -658,7 +670,11 @@ impl gpui::Render for MarkdownText {
|
||||
content,
|
||||
has_padding,
|
||||
} => match decoration {
|
||||
| None => div().min_w_0().child(rich_text(content.clone())),
|
||||
| None => div()
|
||||
.min_w_0()
|
||||
.child(rich_text(content.clone()).on_click(|asd, _, _| {
|
||||
println!("link clicked {:?}", asd);
|
||||
})),
|
||||
| Some(decoration) => div()
|
||||
.w_full()
|
||||
.flex()
|
||||
|
||||
Reference in New Issue
Block a user