Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/markdown/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ pub(super) fn flush_wrapped_spans(
render_width,
);
} else if !spans.is_empty() {
let mut all = block_prefix(false, theme);
all.append(spans);
lines.push(Line::from(all));
push_wrapped_prefixed_lines(lines, spans, vec![], vec![], render_width);
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/markdown/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ pub(super) fn push_wrapped_prefixed_lines(
.saturating_sub(first_prefix_width.max(continuation_prefix_width))
.max(8);

let total_width: usize = body_spans
.iter()
.map(|s| display_width(s.content.as_ref()))
.sum();
if total_width <= max_width {
let mut all = first_prefix;
all.append(body_spans);
lines.push(Line::from(all));
return;
}

let mut current_prefix = first_prefix.clone();
let mut next_prefix = continuation_prefix.clone();
let mut current_width = 0usize;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/markdown_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn blockquote_bold_link_preserves_link_color() {
let theme_colors = &app_theme.markdown;

let bq_line = &lines[0];
let link_span = bq_line.spans.iter().find(|s| s.content.as_ref() == "lien");
let link_span = bq_line.spans.iter().find(|s| s.content.contains("lien"));
assert!(link_span.is_some(), "should find 'lien' span");
let span = link_span.unwrap();
assert_eq!(
Expand Down
Loading