fix: rich text link handling

This commit is contained in:
2026-06-06 23:55:21 +01:00
parent 742311e02c
commit 016b499cb0
2 changed files with 35 additions and 8 deletions

View File

@@ -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()