(8020e48) Quote a comment behind a gutter bar that survives wrapping, and bump to 0.32.4
This commit is contained in:
+323
-67
@@ -23,7 +23,7 @@ use ratatui::text::{Line, Span, Text};
|
||||
use ratatui::widgets::{Block, Borders, Clear, Paragraph, Tabs, Wrap};
|
||||
|
||||
use crate::campaign::{CAMPAIGNS_DIR, CampaignIndex, Standing};
|
||||
use crate::history::{history_cells, history_root, read_history};
|
||||
use crate::history::{HistoryPart, history_parts, history_root, read_history};
|
||||
use crate::tag::{NO_ANNOTATION, TAGS_FILE, TagIndex};
|
||||
use crate::util::*;
|
||||
|
||||
@@ -590,26 +590,61 @@ pub struct Detail {
|
||||
/// card that said so, and the id alone is not an address across several boards:
|
||||
/// acting on the ticket means knowing which project to run the command in.
|
||||
pub project: Option<String>,
|
||||
/// The body as the overlay draws it: lines of styled spans, not a string.
|
||||
/// The body as vertical stretches, each one drawn and measured whole.
|
||||
///
|
||||
/// Styled here rather than painted into the text, because ratatui draws an escape
|
||||
/// sequence in a paragraph as literal bytes, which is 6d327df. It is also the one
|
||||
/// value the clamp and the draw both measure, so neither can wrap it differently
|
||||
/// from the other.
|
||||
pub body: Text<'static>,
|
||||
/// A flow stretch runs full width; a quoted one is laid out as two columns at draw
|
||||
/// time — a gutter the bar fills top to bottom, and the body beside it. That is what
|
||||
/// keeps a comment's bar over every row its prose wraps onto, which a bar riding in
|
||||
/// the text cannot do: the wrapper folds continuations underneath it. Sections are
|
||||
/// also what the clamp measures, summed, so the scroll and the draw cannot disagree
|
||||
/// about where any of them ends.
|
||||
pub sections: Vec<DetailSection>,
|
||||
}
|
||||
|
||||
/// One vertical stretch of the overlay, drawn and measured as a unit.
|
||||
#[derive(Debug)]
|
||||
pub enum DetailSection {
|
||||
/// Description, metadata, mechanical history rows and the blanks between them:
|
||||
/// full width, wrapped by the widget as always.
|
||||
Flow(Text<'static>),
|
||||
/// Somebody's words, from a [`HistoryPart::Quoted`] run. Carries the body only —
|
||||
/// the bar is the gutter the draw lays beside it, not text under which a wrapped
|
||||
/// row would lose it.
|
||||
Quote(Text<'static>),
|
||||
}
|
||||
|
||||
impl DetailSection {
|
||||
fn text(&self) -> &Text<'static> {
|
||||
match self {
|
||||
DetailSection::Flow(text) | DetailSection::Quote(text) => text,
|
||||
}
|
||||
}
|
||||
|
||||
/// The width this section wraps at: the gutter takes its two cells from the rest.
|
||||
fn width(&self, full: u16) -> u16 {
|
||||
match self {
|
||||
DetailSection::Flow(_) => full,
|
||||
DetailSection::Quote(_) => full.saturating_sub(GUTTER_WIDTH),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// How wide a quoted run's gutter is: the bar and the gap before the body, so a quoted
|
||||
/// row reads exactly as wide as one the CLI prefixes.
|
||||
const GUTTER_WIDTH: u16 = 2;
|
||||
|
||||
impl Detail {
|
||||
/// The body as plain text, one line per drawn line.
|
||||
///
|
||||
/// Only the suite asks: it is what an assertion about the body reads, and what shows
|
||||
/// that no escape sequence reached it. Nothing in the draw path needs it, so it is
|
||||
/// not carried alongside the spans where the two could disagree.
|
||||
/// not carried alongside the spans where the two could disagree. A quote's rows carry
|
||||
/// no bar here, since on screen the bar is the gutter and not part of the line.
|
||||
#[cfg(test)]
|
||||
pub fn plain(&self) -> String {
|
||||
self.body
|
||||
.lines
|
||||
self.sections
|
||||
.iter()
|
||||
.flat_map(|section| section.text().lines.iter())
|
||||
.map(|line| {
|
||||
line.spans
|
||||
.iter()
|
||||
@@ -1861,7 +1896,7 @@ impl Board {
|
||||
let text = detail_text_area(Rect::new(0, 0, screen.width, screen.height));
|
||||
// A screenful less a line, so the eye has something to land on after the jump.
|
||||
let step = text.height.saturating_sub(1).max(1) as isize;
|
||||
let last = last_offset(&detail.body, text) as isize;
|
||||
let last = detail_last_offset(&detail.sections, text) as isize;
|
||||
|
||||
self.offset = (self.offset as isize + pages.saturating_mul(step)).clamp(0, last) as u16;
|
||||
}
|
||||
@@ -1997,39 +2032,91 @@ fn detail_of(card: &Card) -> Detail {
|
||||
};
|
||||
|
||||
// Colour on, and nothing here is painted: the body arrives as cells, the relations
|
||||
// as rows and the history block as the cells the CLI paints, and `detail_body`
|
||||
// turns them all into styled spans. An escape sequence never enters, which is what
|
||||
// a ratatui paragraph would draw as literal bytes.
|
||||
// as rows and the history block as segments, and `detail_sections` turns them into
|
||||
// stretches of spans. An escape sequence never enters, which is what a ratatui
|
||||
// paragraph would draw as literal bytes.
|
||||
let mut parts = content_parts(&content, true, &resolved);
|
||||
let mut block = vec![Cell::plain("\n")];
|
||||
// The board carries colour, so the quote bars a comment and a reason draw are the
|
||||
// same cells `show` paints: one layout, two renderers.
|
||||
block.extend(history_cells(&history, true));
|
||||
parts.push(BodyPart::Cells(block));
|
||||
parts.push(BodyPart::Cells(vec![Cell::plain("\n")]));
|
||||
let sections = detail_sections(&parts, &history_parts(&history));
|
||||
|
||||
Detail {
|
||||
title: ticket.title.clone(),
|
||||
id: ticket.id.clone(),
|
||||
project: card.project.clone(),
|
||||
body: detail_body(&parts),
|
||||
sections,
|
||||
}
|
||||
}
|
||||
|
||||
/// The rendered body as lines of spans: the text split where it says, and each relation
|
||||
/// row styled from the cells the CLI paints.
|
||||
/// One piece of the overlay, from either source: the ticket's own body or the log.
|
||||
///
|
||||
/// A part that does not end on a newline runs on into the next one rather than closing a
|
||||
/// line, so the seam between text and relations is wherever the body actually put it and
|
||||
/// not wherever a part happened to end.
|
||||
fn detail_body(parts: &[BodyPart]) -> Text<'static> {
|
||||
/// A private fold over the two input shapes, so [`detail_sections`] takes one walk
|
||||
/// instead of two that could disagree about where a quote begins and ends.
|
||||
enum Piece {
|
||||
Cells(Vec<Cell>),
|
||||
Relations(Vec<RelationRow>),
|
||||
Quoted(String),
|
||||
}
|
||||
|
||||
/// The overlay as vertical sections.
|
||||
///
|
||||
/// Flow pieces accumulate exactly as the one text used to — an unterminated run runs on
|
||||
/// into the next part, so the seam between text and relations is wherever the body put
|
||||
/// it. A quoted piece closes what is open, banks it as its own flow section, and becomes
|
||||
/// a quote section carrying the bare body: the bar is geometry the draw lays beside these
|
||||
/// rows, which is what keeps it over every row the prose wraps onto.
|
||||
///
|
||||
/// The one newline after a quoted run is consumed rather than drawn. It used to close
|
||||
/// the quote's last line; now the section boundary does that, and drawing the newline
|
||||
/// would bank a blank row no entry ever had. History always writes exactly that cell
|
||||
/// after a quote — a comment body and a reason alike — so consuming one leading newline
|
||||
/// from the next flow piece is exact, not heuristic.
|
||||
fn detail_sections(parts: &[BodyPart], history: &[HistoryPart]) -> Vec<DetailSection> {
|
||||
let mut pieces: Vec<Piece> = parts
|
||||
.iter()
|
||||
.map(|part| match part {
|
||||
BodyPart::Cells(cells) => Piece::Cells(cells.clone()),
|
||||
BodyPart::Relations(rows) => Piece::Relations(rows.clone()),
|
||||
})
|
||||
.chain(history.iter().map(|part| match part {
|
||||
HistoryPart::Flow(cells) => Piece::Cells(cells.clone()),
|
||||
HistoryPart::Quoted(body) => Piece::Quoted(body.clone()),
|
||||
}))
|
||||
.collect();
|
||||
|
||||
let mut sections: Vec<DetailSection> = Vec::new();
|
||||
let mut lines: Vec<Line<'static>> = Vec::new();
|
||||
let mut open: Vec<Span<'static>> = Vec::new();
|
||||
// Set while the previous section was a quote, so the next flow piece knows to give
|
||||
// up the newline that closed the quote before sections existed.
|
||||
let mut after_quote = false;
|
||||
|
||||
for part in parts {
|
||||
match part {
|
||||
BodyPart::Cells(cells) => {
|
||||
for piece in pieces.drain(..) {
|
||||
match piece {
|
||||
Piece::Quoted(body) => {
|
||||
if !open.is_empty() {
|
||||
lines.push(Line::from(std::mem::take(&mut open)));
|
||||
}
|
||||
if !lines.is_empty() {
|
||||
sections.push(DetailSection::Flow(Text::from(std::mem::take(&mut lines))));
|
||||
}
|
||||
|
||||
sections.push(DetailSection::Quote(Text::from(
|
||||
body.split('\n')
|
||||
.map(|line| Line::from(span_from(line, None, None)))
|
||||
.collect::<Vec<Line<'static>>>(),
|
||||
)));
|
||||
after_quote = true;
|
||||
}
|
||||
Piece::Cells(cells) => {
|
||||
for cell in cells {
|
||||
let mut rest = cell.text.as_str();
|
||||
if after_quote && rest.starts_with('\n') {
|
||||
after_quote = false;
|
||||
rest = &rest[1..];
|
||||
if rest.is_empty() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
while let Some((line, tail)) = rest.split_once('\n') {
|
||||
if !line.is_empty() {
|
||||
open.push(span_from(line, cell.color, cell.modifier));
|
||||
@@ -2044,8 +2131,8 @@ fn detail_body(parts: &[BodyPart]) -> Text<'static> {
|
||||
}
|
||||
// One line each, from the same cells `render_relations` paints, so the block
|
||||
// cannot read differently here than it does in `show`.
|
||||
BodyPart::Relations(rows) => {
|
||||
for row in relation_cells(rows) {
|
||||
Piece::Relations(rows) => {
|
||||
for row in relation_cells(&rows) {
|
||||
open.extend(row.into_iter().map(span_of));
|
||||
lines.push(Line::from(std::mem::take(&mut open)));
|
||||
}
|
||||
@@ -2056,8 +2143,11 @@ fn detail_body(parts: &[BodyPart]) -> Text<'static> {
|
||||
if !open.is_empty() {
|
||||
lines.push(Line::from(open));
|
||||
}
|
||||
if !lines.is_empty() {
|
||||
sections.push(DetailSection::Flow(Text::from(lines)));
|
||||
}
|
||||
|
||||
Text::from(lines)
|
||||
sections
|
||||
}
|
||||
|
||||
/// A cell as the board draws it: the same text in the same style, as a span.
|
||||
@@ -3962,6 +4052,24 @@ fn last_offset(detail: &Text<'static>, text: Rect) -> u16 {
|
||||
wrapped_height(detail, text.width).saturating_sub(text.height)
|
||||
}
|
||||
|
||||
/// How tall the whole overlay is, section by section.
|
||||
///
|
||||
/// Each section wraps at its own width — a quote's body shares its row with the gutter —
|
||||
/// and the total is what the clamp and the indicator are derived from. One measurement
|
||||
/// per section by the same [`wrapped_height`], so the draw and the scroll cannot
|
||||
/// disagree about where any of them ends.
|
||||
fn detail_height(sections: &[DetailSection], width: u16) -> u16 {
|
||||
sections
|
||||
.iter()
|
||||
.map(|section| wrapped_height(section.text(), section.width(width)))
|
||||
.fold(0u16, |total, height| total.saturating_add(height))
|
||||
}
|
||||
|
||||
/// The furthest the overlay scrolls: every section's wrapped height less the viewport.
|
||||
fn detail_last_offset(sections: &[DetailSection], text: Rect) -> u16 {
|
||||
detail_height(sections, text.width).saturating_sub(text.height)
|
||||
}
|
||||
|
||||
/// The step `scroll_detail` takes, a screenful less the line kept for overlap.
|
||||
///
|
||||
/// The page numbers are counted in it rather than in whole screenfuls, so the pages the
|
||||
@@ -4021,7 +4129,7 @@ fn draw_detail(frame: &mut Frame, detail: &Detail, offset: u16, area: Rect) {
|
||||
// terminal may have been resized since, and a ticket read to its end can grow
|
||||
// shorter under a tick. Which is also what repages the indicator, since the wrapped
|
||||
// count and the viewport both move with the width.
|
||||
let last = wrapped_height(&detail.body, text.width).saturating_sub(text.height);
|
||||
let last = detail_last_offset(&detail.sections, text);
|
||||
let offset = offset.min(last);
|
||||
|
||||
let mut block = Block::default()
|
||||
@@ -4044,13 +4152,68 @@ fn draw_detail(frame: &mut Frame, detail: &Detail, offset: u16, area: Rect) {
|
||||
}
|
||||
|
||||
frame.render_widget(Clear, overlay);
|
||||
frame.render_widget(
|
||||
Paragraph::new(detail.body.clone())
|
||||
.block(block)
|
||||
.wrap(Wrap { trim: false })
|
||||
.scroll((offset, 0)),
|
||||
overlay,
|
||||
);
|
||||
frame.render_widget(block, overlay);
|
||||
|
||||
// The sections stack into one scroll: `top` walks the virtual rows, each section is
|
||||
// clipped to what the viewport still holds, and one straddling the top is scrolled
|
||||
// within itself by however much of it is above. The bar of a quote rides in its own
|
||||
// column, so scrolling never has to move it.
|
||||
let mut top: u16 = 0;
|
||||
for section in &detail.sections {
|
||||
let height = wrapped_height(section.text(), section.width(text.width));
|
||||
let bottom = top.saturating_add(height);
|
||||
let visible = bottom > offset && top < offset.saturating_add(text.height);
|
||||
|
||||
if visible {
|
||||
let within = offset.saturating_sub(top);
|
||||
let y = text.y + top.max(offset) - offset;
|
||||
let clip = Rect {
|
||||
x: text.x,
|
||||
y,
|
||||
width: text.width,
|
||||
height: text.bottom().saturating_sub(y),
|
||||
};
|
||||
|
||||
match section {
|
||||
DetailSection::Flow(body) => frame.render_widget(
|
||||
Paragraph::new(body.clone())
|
||||
.wrap(Wrap { trim: false })
|
||||
.scroll((within, 0)),
|
||||
clip,
|
||||
),
|
||||
DetailSection::Quote(body) => {
|
||||
let [bars, prose] =
|
||||
Layout::horizontal([Constraint::Length(GUTTER_WIDTH), Constraint::Min(0)])
|
||||
.areas(clip);
|
||||
|
||||
frame.render_widget(gutter_bars(clip.height), bars);
|
||||
frame.render_widget(
|
||||
Paragraph::new(body.clone())
|
||||
.wrap(Wrap { trim: false })
|
||||
.scroll((within, 0)),
|
||||
prose,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
top = bottom;
|
||||
if top >= offset.saturating_add(text.height) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The gutter beside a quoted run: the bar repeated down every row the run occupies.
|
||||
///
|
||||
/// Geometry rather than text, which is the whole point — a comment's prose wraps inside
|
||||
/// the body column and cannot take the mark off any row, paragraph breaks included.
|
||||
/// Grey, as chrome; [`QUOTE_BAR`] for the same reason the CLI prefixes with it, so both
|
||||
/// renderers draw one glyph.
|
||||
fn gutter_bars(height: u16) -> Text<'static> {
|
||||
let bar = Span::styled(format!("{QUOTE_BAR} "), Style::default().fg(Color::Grey.into()));
|
||||
|
||||
Text::from(vec![Line::from(bar); height as usize])
|
||||
}
|
||||
|
||||
/// The overlay's title: the short id and the name of the ticket it has open.
|
||||
@@ -4190,6 +4353,24 @@ mod tests {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The overlay's text rows, cut out of the drawn screen by the layout's own
|
||||
/// geometry, right-trimmed so an assertion reads what is on it rather than its
|
||||
/// padding.
|
||||
fn overlay_text_rows(lines: &[String], width: u16, height: u16) -> Vec<String> {
|
||||
let text = detail_text_area(Rect::new(0, 0, width, height));
|
||||
lines[text.y as usize..(text.y + text.height) as usize]
|
||||
.iter()
|
||||
.map(|row| {
|
||||
row.chars()
|
||||
.skip(text.x as usize)
|
||||
.take(text.width as usize)
|
||||
.collect::<String>()
|
||||
.trim_end()
|
||||
.to_string()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The column headings, which sit on the top border row.
|
||||
///
|
||||
/// That row alone, because the footer names done as well: a whole-screen search for
|
||||
@@ -5495,22 +5676,43 @@ mod tests {
|
||||
assert_eq!(span_color(&change, "claude"), Some(tag_color("claude").into()));
|
||||
assert_eq!(span_color(&change, "2026-08-21 12:00:00"), Some(Color::Cyan.into()));
|
||||
|
||||
// The quote bar rides in the same cells: grey, and carrying the gap before the
|
||||
// text so a pipe can replace the pair with its width.
|
||||
// The quote's rows carry no bar span any more — the bar is the gutter the draw
|
||||
// lays beside them — so what says so on screen is a grey bar cell inside the
|
||||
// overlay, distinct from the border's own verticals by its colour.
|
||||
let said = body_line(detail, "And why.");
|
||||
assert_eq!(span_color(&said, "│ "), Some(Color::Grey.into()));
|
||||
assert!(!said.spans.iter().any(|span| span.content.contains(QUOTE_BAR)));
|
||||
// Held as text rather than through the borrow: the board is scrolled below.
|
||||
let plain = detail.plain();
|
||||
|
||||
// The log ends the overlay, so the gutter is on the last page.
|
||||
for _ in 0..20 {
|
||||
board.scroll_detail(1, SCREEN);
|
||||
}
|
||||
|
||||
let mut terminal = Terminal::new(TestBackend::new(SCREEN.width, SCREEN.height)).unwrap();
|
||||
terminal.draw(|frame| draw(frame, &board)).unwrap();
|
||||
let buffer = terminal.backend().buffer().clone();
|
||||
let overlay = detail_overlay(Rect::new(0, 0, SCREEN.width, SCREEN.height));
|
||||
let grey: ratatui::style::Color = Color::Grey.into();
|
||||
let bars = (overlay.y..overlay.bottom())
|
||||
.flat_map(|y| (overlay.x..overlay.right()).map(move |x| (x, y)))
|
||||
.filter(|&(x, y)| {
|
||||
let cell = &buffer[(x, y)];
|
||||
cell.symbol() == QUOTE_BAR && cell.fg == grey
|
||||
})
|
||||
.count();
|
||||
assert!(bars > 0, "no grey gutter bar reached the screen");
|
||||
|
||||
// The other half: the colour arrived as styles, not as bytes.
|
||||
assert!(
|
||||
!detail.plain().contains('\x1b'),
|
||||
"escapes reached the detail view: {:?}",
|
||||
detail.plain()
|
||||
);
|
||||
assert!(!plain.contains('\x1b'), "escapes reached the detail view: {plain:?}");
|
||||
}
|
||||
|
||||
/// The bar is laid out where both renderers read it, so a pasted body draws every
|
||||
/// line behind it in the overlay too — not only its first, which is the bug this
|
||||
/// shape replaced.
|
||||
/// The bar is geometry over the rows a comment occupies, not text riding on each
|
||||
/// stored line's first characters: the reported bug was that ratatui's word wrap
|
||||
/// folds a long line onto continuation rows the prefix never reaches, so the quote
|
||||
/// read as ending halfway through. Every drawn row of the run is asserted here,
|
||||
/// wrapped continuations and the paragraph break included, and no row after it may
|
||||
/// carry a bar either — a stray one would be a quote wider than its body.
|
||||
#[test]
|
||||
fn the_detail_view_draws_every_line_of_a_comment_behind_the_bar() {
|
||||
let dir = board_dir();
|
||||
@@ -5519,22 +5721,61 @@ mod tests {
|
||||
|
||||
let history = crate::history::history_dir(&dir, uuid);
|
||||
std::fs::create_dir_all(&history).unwrap();
|
||||
// One stored line long enough to wrap onto several drawn rows, then a second
|
||||
// paragraph behind its own break: the two ways the old shape lost the bar.
|
||||
let long_line = "alpha bravo charlie delta echo foxtrot golf hotel india juliet \
|
||||
kilo lima mike november oscar papa quebec romeo sierra tango uniform victor \
|
||||
whiskey xray yankee zulu";
|
||||
std::fs::write(
|
||||
history.join("20260821_120000_000000_comment.md"),
|
||||
"**Comment**\nFirst line.\n\nSecond line.\n\n**Author**: bob\n**Time**: \
|
||||
2026-08-21 12:00:00\n",
|
||||
format!(
|
||||
"**Comment**\n{long_line}\n\nSecond paragraph.\n\n**Author**: bob\n**Time**: \
|
||||
2026-08-21 12:00:00\n"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.toggle_detail();
|
||||
let plain = board.detail.as_ref().expect("no detail").plain();
|
||||
// The log ends the overlay, so the last page is the one that holds the run.
|
||||
for _ in 0..20 {
|
||||
board.scroll_detail(1, SCREEN);
|
||||
}
|
||||
|
||||
let screen = render(&board, SCREEN.width, SCREEN.height);
|
||||
let rows = overlay_text_rows(&screen, SCREEN.width, SCREEN.height);
|
||||
let header = rows
|
||||
.iter()
|
||||
.position(|row| row.starts_with("From bob"))
|
||||
.expect("the comment's header is not on screen");
|
||||
|
||||
// The run: every row after the header up to the first one without a bar.
|
||||
let mut at = header + 1;
|
||||
while rows.get(at).is_some_and(|row| row.starts_with(QUOTE_BAR)) {
|
||||
at += 1;
|
||||
}
|
||||
let run = header + 1..at;
|
||||
assert!(
|
||||
plain.contains("│ First line.\n│\n│ Second line."),
|
||||
"the run is not quoted start to finish:\n{plain}"
|
||||
run.len() >= 4,
|
||||
"the fixture should wrap onto several rows, drew {run:?}:\n{rows:#?}"
|
||||
);
|
||||
|
||||
// Nothing outside the run is quoted: no stray bar above or below the block.
|
||||
assert!(
|
||||
rows[at..].iter().all(|row| !row.contains(QUOTE_BAR)),
|
||||
"a row past the comment carries a bar:\n{rows:#?}"
|
||||
);
|
||||
|
||||
// The break sits inside the run as the bare glyph, and the second paragraph
|
||||
// follows it behind the same bar.
|
||||
assert!(
|
||||
rows[run.clone()].iter().any(|row| row == QUOTE_BAR),
|
||||
"no bare bar on the paragraph break:\n{rows:#?}"
|
||||
);
|
||||
assert!(
|
||||
rows[run].iter().any(|row| row.starts_with("│ Second")),
|
||||
"the second paragraph lost the bar:\n{rows:#?}"
|
||||
);
|
||||
assert!(!plain.contains('\x1b'), "escapes reached the detail view: {plain:?}");
|
||||
}
|
||||
|
||||
/// The board and `show` share one layout, so the reason a move carries renders
|
||||
@@ -5559,12 +5800,27 @@ mod tests {
|
||||
board.toggle_detail();
|
||||
let plain = board.detail.as_ref().expect("no detail").plain();
|
||||
|
||||
// The board carries colour, so the bar itself is on screen where a pipe would
|
||||
// draw two spaces: same cells, one layout.
|
||||
let expected = "status reviewing → backlog claude (2026-08-21 12:00:00)\n│ sent back, wrong \
|
||||
approach";
|
||||
// The reason is its own quoted stretch under the row it explains; its rows carry
|
||||
// no bar in the text, since on screen the bar is the gutter beside them.
|
||||
let expected = "status reviewing → backlog claude (2026-08-21 12:00:00)\nsent back, wrong \
|
||||
approach";
|
||||
assert!(plain.contains(expected), "{plain}");
|
||||
assert!(!plain.contains('\x1b'), "escapes reached the detail view: {plain:?}");
|
||||
assert!(!plain.contains(QUOTE_BAR), "the bar reached the text: {plain:?}");
|
||||
|
||||
// And on screen the bar stands beside it, once the log is scrolled into view.
|
||||
for _ in 0..20 {
|
||||
board.scroll_detail(1, SCREEN);
|
||||
}
|
||||
let screen = render(&board, SCREEN.width, SCREEN.height);
|
||||
let rows = overlay_text_rows(&screen, SCREEN.width, SCREEN.height);
|
||||
let status = rows
|
||||
.iter()
|
||||
.position(|row| row.starts_with("status "))
|
||||
.expect("the mechanical row is not on screen");
|
||||
assert!(
|
||||
rows[status + 1].starts_with(&format!("{QUOTE_BAR} sent back")),
|
||||
"the reason did not draw behind the bar:\n{rows:#?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The reported bug: the modal showed a description, criteria and a metadata
|
||||
@@ -7424,7 +7680,7 @@ mod tests {
|
||||
board.toggle_detail();
|
||||
|
||||
let area = detail_text_area(Rect::new(0, 0, SCREEN.width, SCREEN.height));
|
||||
let last = last_offset(&board.detail.as_ref().unwrap().body, area);
|
||||
let last = detail_last_offset(&board.detail.as_ref().unwrap().sections, area);
|
||||
assert!(last > 0, "the fixture fits on one screen, so nothing is measured");
|
||||
|
||||
// Far past the end, so the clamp is what stops it.
|
||||
@@ -7450,9 +7706,9 @@ mod tests {
|
||||
/// is drawn in rather than reading the flattened text.
|
||||
fn body_line(detail: &Detail, needle: &str) -> Line<'static> {
|
||||
detail
|
||||
.body
|
||||
.lines
|
||||
.sections
|
||||
.iter()
|
||||
.flat_map(|section| section.text().lines.iter())
|
||||
.find(|line| {
|
||||
line.spans
|
||||
.iter()
|
||||
@@ -7806,7 +8062,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let text = detail_text_area(Rect::new(0, 0, SCREEN.width, SCREEN.height));
|
||||
let last = last_offset(&board.detail.as_ref().unwrap().body, text);
|
||||
let last = detail_last_offset(&board.detail.as_ref().unwrap().sections, text);
|
||||
assert_eq!(board.offset, last, "the fixture did not reach the end");
|
||||
|
||||
let screen = render(&board, SCREEN.width, SCREEN.height);
|
||||
@@ -7838,7 +8094,7 @@ mod tests {
|
||||
|
||||
let text = detail_text_area(Rect::new(0, 0, width, height));
|
||||
assert_eq!(
|
||||
last_offset(&board.detail.as_ref().unwrap().body, text),
|
||||
detail_last_offset(&board.detail.as_ref().unwrap().sections, text),
|
||||
0,
|
||||
"the fixture scrolls, so it proves nothing"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user