fix insert_history modifier handling (#1774)

This fixes a bug in insert_history_lines where writing
`Line::From(vec!["A".bold(), "B".into()])` would write "B" as bold,
because "B" didn't explicitly subtract bold.
This commit is contained in:
Jeremy Rose
2025-08-01 10:37:43 -07:00
committed by GitHub
parent f918198bbb
commit 8360c6a3ec
2 changed files with 52 additions and 25 deletions

View File

@@ -545,24 +545,17 @@ impl HistoryCell {
} else {
for (idx, PlanItemArg { step, status }) in plan.into_iter().enumerate() {
let num = idx + 1;
let (icon, style): (&str, Style) = match status {
StepStatus::Completed => ("", Style::default().fg(Color::Green)),
StepStatus::InProgress => (
"",
Style::default()
.fg(Color::Yellow)
.add_modifier(Modifier::BOLD),
),
StepStatus::Pending => ("", Style::default().fg(Color::Gray)),
let icon_span: Span = match status {
StepStatus::Completed => Span::from("").fg(Color::Green),
StepStatus::InProgress => Span::from("").fg(Color::Yellow).bold(),
StepStatus::Pending => Span::from("").fg(Color::Gray),
};
let prefix = vec![
Span::raw(format!("{num:>2}. [")),
Span::styled(icon.to_string(), style),
Span::raw("] "),
];
let mut spans = prefix;
spans.push(Span::raw(step));
lines.push(Line::from(spans));
lines.push(Line::from(vec![
format!("{num:>2}. [").into(),
icon_span,
"] ".into(),
step.into(),
]));
}
}