Reformat with cargo fmt, and nothing else
Layout only, no behaviour and no wording. 161 hunks across 22 files, 98 of them rustfmt joining a call or a message onto the one line it fits on. The config it formats to, and how its four numbers were arrived at, is the commit before this one. Separate so that it is reviewable by not being read: nothing here is a decision, and every decision is next door. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
964ca342d8
commit
73ffcad733
+78
-112
@@ -6,19 +6,19 @@
|
||||
//!
|
||||
//! **Read only.** Moving a card by keypress is a follow-up. Everything here observes.
|
||||
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||
use ratatui::Frame;
|
||||
use ratatui::layout::{Constraint, Direction, Layout, Margin, Rect, Size};
|
||||
use ratatui::style::{Modifier, Style};
|
||||
use ratatui::text::{Line, Span, Text};
|
||||
use ratatui::widgets::{Block, Borders, Clear, Paragraph, Tabs, Wrap};
|
||||
use ratatui::Frame;
|
||||
|
||||
use crate::handlers::read_comments;
|
||||
use crate::util::*;
|
||||
@@ -71,10 +71,7 @@ pub fn projects(paths: &[PathBuf], start: &Path) -> Result<Vec<Project>> {
|
||||
continue;
|
||||
}
|
||||
|
||||
projects.push(Project {
|
||||
name: project_name(&dir),
|
||||
dir,
|
||||
});
|
||||
projects.push(Project { name: project_name(&dir), dir });
|
||||
}
|
||||
|
||||
Ok(projects)
|
||||
@@ -315,11 +312,7 @@ impl Board {
|
||||
if projects.len() > 1 {
|
||||
tabs.push(Tab::new(ALL.to_string()));
|
||||
}
|
||||
tabs.extend(
|
||||
projects
|
||||
.iter()
|
||||
.map(|project| Tab::new(project.name.clone())),
|
||||
);
|
||||
tabs.extend(projects.iter().map(|project| Tab::new(project.name.clone())));
|
||||
|
||||
let mut board = Board {
|
||||
tabs,
|
||||
@@ -775,10 +768,7 @@ fn detail_of(card: &Card) -> Detail {
|
||||
// Colour off for the text, which is what keeps escapes out of the paragraph, and the
|
||||
// relations arrive as rows so the board can style them itself.
|
||||
let mut parts = content_parts(&content, false, &resolved);
|
||||
parts.push(BodyPart::Text(format!(
|
||||
"\n{}",
|
||||
format_comments_with(&comments, false)
|
||||
)));
|
||||
parts.push(BodyPart::Text(format!("\n{}", format_comments_with(&comments, false))));
|
||||
|
||||
Detail {
|
||||
title: ticket.title.clone(),
|
||||
@@ -1136,12 +1126,7 @@ fn draw_columns(frame: &mut Frame, board: &Board, area: Rect) {
|
||||
};
|
||||
|
||||
// An empty status is an empty column, not a column that is not there.
|
||||
frame.render_widget(
|
||||
Paragraph::new(lines)
|
||||
.block(block)
|
||||
.scroll((offset, 0)),
|
||||
areas[index],
|
||||
);
|
||||
frame.render_widget(Paragraph::new(lines).block(block).scroll((offset, 0)), areas[index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1285,12 +1270,11 @@ fn card_lines(card: &Card, selected: bool, width: u16) -> Vec<Line<'static>> {
|
||||
|
||||
let mut lines = vec![corner_line(left, due_span(&ticket.due), width)];
|
||||
|
||||
lines.extend(title_lines(&ticket.title, width).into_iter().map(|line| {
|
||||
Line::from(Span::styled(
|
||||
line,
|
||||
Style::default().add_modifier(emphasis),
|
||||
))
|
||||
}));
|
||||
lines.extend(
|
||||
title_lines(&ticket.title, width)
|
||||
.into_iter()
|
||||
.map(|line| Line::from(Span::styled(line, Style::default().add_modifier(emphasis)))),
|
||||
);
|
||||
|
||||
if let Some(row) = tags_line(&ticket.tags, width) {
|
||||
lines.push(row);
|
||||
@@ -1352,10 +1336,7 @@ fn tags_line(tags: &[String], width: u16) -> Option<Line<'static>> {
|
||||
if index > 0 {
|
||||
spans.push(Span::raw(" "));
|
||||
}
|
||||
spans.push(Span::styled(
|
||||
format!("#{tag}"),
|
||||
Style::default().fg(tag_color(tag).into()),
|
||||
));
|
||||
spans.push(Span::styled(format!("#{tag}"), Style::default().fg(tag_color(tag).into())));
|
||||
}
|
||||
|
||||
Some(Line::from(spans))
|
||||
@@ -1399,10 +1380,7 @@ fn due_span(due: &str) -> Option<Span<'static>> {
|
||||
false => Color::Cyan,
|
||||
};
|
||||
|
||||
Some(Span::styled(
|
||||
due_date(due).to_string(),
|
||||
Style::default().fg(colour.into()),
|
||||
))
|
||||
Some(Span::styled(due_date(due).to_string(), Style::default().fg(colour.into())))
|
||||
}
|
||||
|
||||
/// `left` at the left, `right` at the right, with the gap between them.
|
||||
@@ -1490,10 +1468,7 @@ fn title_lines(title: &str, width: u16) -> Vec<String> {
|
||||
|
||||
fn chars_in_chunks(word: &str, width: usize) -> Vec<String> {
|
||||
let chars: Vec<char> = word.chars().collect();
|
||||
chars
|
||||
.chunks(width)
|
||||
.map(|chunk| chunk.iter().collect())
|
||||
.collect()
|
||||
chars.chunks(width).map(|chunk| chunk.iter().collect()).collect()
|
||||
}
|
||||
|
||||
/// The row with an ellipsis on the end, making room for it if the row is full.
|
||||
@@ -1574,10 +1549,7 @@ fn draw_notice(frame: &mut Frame, notice: &Notice, area: Rect) {
|
||||
false => Style::default(),
|
||||
};
|
||||
|
||||
frame.render_widget(
|
||||
Paragraph::new(Span::styled(format!(" {}", notice.text), style)),
|
||||
area,
|
||||
);
|
||||
frame.render_widget(Paragraph::new(Span::styled(format!(" {}", notice.text), style)), area);
|
||||
}
|
||||
|
||||
/// The prompt, in place of the key list it would otherwise describe wrongly.
|
||||
@@ -1595,10 +1567,7 @@ fn draw_search(frame: &mut Frame, search: &Search, area: Rect) {
|
||||
let mut spans = vec![Span::raw(prompt.clone())];
|
||||
|
||||
if search.missed {
|
||||
spans.push(Span::styled(
|
||||
" no match",
|
||||
Style::default().fg(Color::BrightRed.into()),
|
||||
));
|
||||
spans.push(Span::styled(" no match", Style::default().fg(Color::BrightRed.into())));
|
||||
}
|
||||
spans.push(Span::styled(
|
||||
" enter jump esc cancel ",
|
||||
@@ -1737,11 +1706,8 @@ fn draw_detail(frame: &mut Frame, detail: &Detail, offset: u16, area: Rect) {
|
||||
// keys and a rendered checkbox take, and does not compete with the orange title.
|
||||
if let Some(indicator) = page_indicator(offset, last, text.height, overlay.width) {
|
||||
block = block.title_bottom(
|
||||
Line::from(Span::styled(
|
||||
indicator,
|
||||
Style::default().fg(Color::Grey.into()),
|
||||
))
|
||||
.right_aligned(),
|
||||
Line::from(Span::styled(indicator, Style::default().fg(Color::Grey.into())))
|
||||
.right_aligned(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1865,10 +1831,7 @@ mod tests {
|
||||
|
||||
/// The screen the scrolling tests draw on, so the keypress and the draw measure the
|
||||
/// same overlay.
|
||||
const SCREEN: Size = Size {
|
||||
width: 120,
|
||||
height: 20,
|
||||
};
|
||||
const SCREEN: Size = Size { width: 120, height: 20 };
|
||||
|
||||
/// The rendered buffer as lines of text, escapes and styling dropped.
|
||||
fn render(board: &Board, width: u16, height: u16) -> Vec<String> {
|
||||
@@ -2191,7 +2154,8 @@ mod tests {
|
||||
/// it drops styling on the way out of the buffer.
|
||||
fn card_colour(dir: &Path, width: u16, needle: &str) -> Option<ratatui::style::Color> {
|
||||
let board = one_board(dir);
|
||||
let inner = card_width(Size { width, height: 20 }, board.tabbed(), board.visible().len(), 0);
|
||||
let inner =
|
||||
card_width(Size { width, height: 20 }, board.tabbed(), board.visible().len(), 0);
|
||||
let ticket = board.selected().expect("no card");
|
||||
|
||||
card_lines(ticket, false, inner)
|
||||
@@ -2432,7 +2396,8 @@ mod tests {
|
||||
let dir = board_dir();
|
||||
let before = digest(&dir);
|
||||
|
||||
let path = write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
let path =
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
let created = digest(&dir);
|
||||
assert_ne!(before, created, "a new ticket went unnoticed");
|
||||
|
||||
@@ -2448,7 +2413,8 @@ mod tests {
|
||||
#[test]
|
||||
fn the_digest_moves_when_a_ticket_is_edited_in_place() {
|
||||
let dir = board_dir();
|
||||
let path = write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
let path =
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
let before = digest(&dir);
|
||||
|
||||
let content = std::fs::read_to_string(&path).unwrap();
|
||||
@@ -2462,7 +2428,8 @@ mod tests {
|
||||
#[test]
|
||||
fn the_digest_moves_on_an_edit_of_the_same_length() {
|
||||
let dir = board_dir();
|
||||
let path = write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
let path =
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
let content = std::fs::read_to_string(&path).unwrap();
|
||||
let same_length = content.replace("A description.", "A descriptionA");
|
||||
@@ -2534,7 +2501,11 @@ mod tests {
|
||||
#[test]
|
||||
fn the_card_index_is_clamped_when_the_column_is_shorter() {
|
||||
let dir = board_dir();
|
||||
for (n, title) in [("11111111", "Alpha"), ("22222222", "Beta"), ("33333333", "Gamma")] {
|
||||
for (n, title) in [
|
||||
("11111111", "Alpha"),
|
||||
("22222222", "Beta"),
|
||||
("33333333", "Gamma"),
|
||||
] {
|
||||
write_ticket(&dir, "backlog", &format!("{n}-0000-4000-8000-000000000000"), title, "");
|
||||
}
|
||||
write_ticket(&dir, "committed", "44444444-0000-4000-8000-000000000000", "Delta", "");
|
||||
@@ -2572,10 +2543,7 @@ mod tests {
|
||||
|
||||
let top = render(&board, SCREEN.width, SCREEN.height).join("\n");
|
||||
assert!(top.contains("Ticket 01"), "{top}");
|
||||
assert!(
|
||||
!top.contains("Ticket 12"),
|
||||
"the fixture fits without scrolling:\n{top}"
|
||||
);
|
||||
assert!(!top.contains("Ticket 12"), "the fixture fits without scrolling:\n{top}");
|
||||
|
||||
board.select_card(11, SCREEN);
|
||||
|
||||
@@ -2693,10 +2661,7 @@ mod tests {
|
||||
// holding a scroll position for a highlight it no longer has.
|
||||
assert_eq!(board.current().card, 2);
|
||||
let back = render(&board, SCREEN.width, SCREEN.height).join("\n");
|
||||
assert!(
|
||||
back.contains("Ticket 03"),
|
||||
"returning lost the selection:\n{back}"
|
||||
);
|
||||
assert!(back.contains("Ticket 03"), "returning lost the selection:\n{back}");
|
||||
assert!(!back.contains("Ticket 12"), "{back}");
|
||||
}
|
||||
|
||||
@@ -2708,10 +2673,7 @@ mod tests {
|
||||
fill_column(&dir, "backlog", 12);
|
||||
|
||||
// Tall enough that every card fits, so the keypress stores no scroll at all.
|
||||
let roomy = Size {
|
||||
width: 120,
|
||||
height: 60,
|
||||
};
|
||||
let roomy = Size { width: 120, height: 60 };
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.select_card(11, roomy);
|
||||
@@ -2804,7 +2766,11 @@ mod tests {
|
||||
}
|
||||
|
||||
let screen = render(&board, SCREEN.width, SCREEN.height);
|
||||
assert!(screen.join("\n").contains("Line 060"), "nothing scrolled:\n{}", screen.join("\n"));
|
||||
assert!(
|
||||
screen.join("\n").contains("Line 060"),
|
||||
"nothing scrolled:\n{}",
|
||||
screen.join("\n")
|
||||
);
|
||||
|
||||
let row = overlay_title_row(&screen, SCREEN.width, SCREEN.height);
|
||||
assert!(row.contains("(1111111)"), "the id scrolled away:\n{row}");
|
||||
@@ -2956,10 +2922,7 @@ mod tests {
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
// Tall enough that the whole ticket is on screen at once.
|
||||
let roomy = Size {
|
||||
width: 120,
|
||||
height: 60,
|
||||
};
|
||||
let roomy = Size { width: 120, height: 60 };
|
||||
|
||||
let mut board = one_board(&dir);
|
||||
board.toggle_detail();
|
||||
@@ -3203,7 +3166,13 @@ mod tests {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "Alpha first", "");
|
||||
write_ticket(&dir, "backlog", "22222222-0000-4000-8000-000000000000", "Beta second", "");
|
||||
write_ticket(&dir, "committed", "33333333-0000-4000-8000-000000000000", "Gamma third", "");
|
||||
write_ticket(
|
||||
&dir,
|
||||
"committed",
|
||||
"33333333-0000-4000-8000-000000000000",
|
||||
"Gamma third",
|
||||
"",
|
||||
);
|
||||
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Delta finished", "");
|
||||
dir
|
||||
}
|
||||
@@ -3522,8 +3491,7 @@ mod tests {
|
||||
board.open_search();
|
||||
type_query(&mut board, "gam");
|
||||
|
||||
let mut terminal =
|
||||
Terminal::new(TestBackend::new(SCREEN.width, SCREEN.height)).unwrap();
|
||||
let mut terminal = Terminal::new(TestBackend::new(SCREEN.width, SCREEN.height)).unwrap();
|
||||
terminal.draw(|frame| draw(frame, &board)).unwrap();
|
||||
|
||||
let at = terminal.get_cursor_position().unwrap();
|
||||
@@ -3696,9 +3664,9 @@ mod tests {
|
||||
the OSC 52 write is named"
|
||||
);
|
||||
|
||||
let cleared = source.find("board.clear_notice();").expect(
|
||||
"a notice that nothing clears sits in the footer for the rest of the session",
|
||||
);
|
||||
let cleared = source
|
||||
.find("board.clear_notice();")
|
||||
.expect("a notice that nothing clears sits in the footer for the rest of the session");
|
||||
let prompt = source.find("if board.search_key(key, screen)").unwrap();
|
||||
assert!(
|
||||
cleared < prompt,
|
||||
@@ -3883,10 +3851,7 @@ mod tests {
|
||||
|
||||
assert_eq!(project_label("alpha", 38, IDENTITY).as_deref(), Some("alpha"));
|
||||
// Room for three characters of a longer name, the last of them the ellipsis.
|
||||
assert_eq!(
|
||||
project_label("factry-core", 16, IDENTITY).as_deref(),
|
||||
Some("fa…")
|
||||
);
|
||||
assert_eq!(project_label("factry-core", 16, IDENTITY).as_deref(), Some("fa…"));
|
||||
assert_eq!(project_label("factry-core", 13, IDENTITY), None);
|
||||
assert_eq!(project_label("alpha", 4, IDENTITY), None);
|
||||
}
|
||||
@@ -3984,10 +3949,7 @@ mod tests {
|
||||
assert!(!marked_blocked(&board, "The waiter"));
|
||||
|
||||
let screen = render(&board, 120, 20).join("\n");
|
||||
assert!(
|
||||
!screen.contains(BLOCKED_MARK),
|
||||
"a cleared blocker still marked:\n{screen}"
|
||||
);
|
||||
assert!(!screen.contains(BLOCKED_MARK), "a cleared blocker still marked:\n{screen}");
|
||||
}
|
||||
|
||||
/// One open blocker out of two is still a reason not to start, the rule `mv` applies
|
||||
@@ -4056,7 +4018,11 @@ mod tests {
|
||||
assert!(wide[0].contains(BLOCKED_MARK), "no mark with room for it: {:?}", wide[0]);
|
||||
|
||||
let narrow = card_rows(&board, "The waiter", identity);
|
||||
assert!(!narrow[0].contains(BLOCKED_MARK), "mark kept over the column: {:?}", narrow[0]);
|
||||
assert!(
|
||||
!narrow[0].contains(BLOCKED_MARK),
|
||||
"mark kept over the column: {:?}",
|
||||
narrow[0]
|
||||
);
|
||||
assert!(narrow[0].contains(&id), "the identity gave way instead: {:?}", narrow[0]);
|
||||
assert!(narrow[0].chars().count() <= identity as usize, "row over the column");
|
||||
}
|
||||
@@ -4209,8 +4175,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// The style of the first cell drawing `symbol`, so a test can ask what colour a
|
||||
/// glyph actually reached the screen in rather than trusting the span it was built
|
||||
/// from.
|
||||
@@ -4291,16 +4255,20 @@ mod tests {
|
||||
let mut board = one_board(&dir);
|
||||
board.toggle_detail();
|
||||
|
||||
let content = std::fs::read_to_string(
|
||||
board.selected().expect("no selection").ticket.path.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let content =
|
||||
std::fs::read_to_string(board.selected().expect("no selection").ticket.path.clone())
|
||||
.unwrap();
|
||||
let rows = relations_for(&content, &dir).unwrap();
|
||||
let printed = render_relations(&rows, false);
|
||||
|
||||
assert!(!printed.is_empty(), "the fixture has no relations");
|
||||
assert!(
|
||||
board.detail.as_ref().unwrap().plain().contains(printed.trim_end()),
|
||||
board
|
||||
.detail
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.plain()
|
||||
.contains(printed.trim_end()),
|
||||
"the overlay drew a different block than the listing prints: {printed:?}"
|
||||
);
|
||||
}
|
||||
@@ -4467,7 +4435,10 @@ mod tests {
|
||||
let text = &board.detail.as_ref().expect("no detail").plain();
|
||||
// Marked for its kind, and the mark sits ahead of the id.
|
||||
assert!(
|
||||
text.contains(&format!("blocked by {BLOCKED_MARK} {} (2222222) The target", status_mark(Some("backlog")).0)),
|
||||
text.contains(&format!(
|
||||
"blocked by {BLOCKED_MARK} {} (2222222) The target",
|
||||
status_mark(Some("backlog")).0
|
||||
)),
|
||||
"{text:?}"
|
||||
);
|
||||
assert!(!text.contains(target), "the bare uuid was drawn: {text:?}");
|
||||
@@ -4494,7 +4465,10 @@ mod tests {
|
||||
|
||||
let text = &board.detail.as_ref().expect("no detail").plain();
|
||||
assert!(
|
||||
text.contains(&format!("blocks {BLOCKED_MARK} {} (1111111) A holder", status_mark(Some("backlog")).0)),
|
||||
text.contains(&format!(
|
||||
"blocks {BLOCKED_MARK} {} (1111111) A holder",
|
||||
status_mark(Some("backlog")).0
|
||||
)),
|
||||
"{text:?}"
|
||||
);
|
||||
}
|
||||
@@ -4741,11 +4715,7 @@ mod tests {
|
||||
/// Located on the bottom border row rather than by searching the buffer for a glyph:
|
||||
/// `p` and `g` are all over the board, and `drawn_color` would answer about whichever
|
||||
/// card holds the first one.
|
||||
fn indicator_color(
|
||||
board: &Board,
|
||||
width: u16,
|
||||
height: u16,
|
||||
) -> Option<ratatui::style::Color> {
|
||||
fn indicator_color(board: &Board, width: u16, height: u16) -> Option<ratatui::style::Color> {
|
||||
let mut terminal = Terminal::new(TestBackend::new(width, height)).unwrap();
|
||||
terminal.draw(|frame| draw(frame, board)).unwrap();
|
||||
let buffer = terminal.backend().buffer().clone();
|
||||
@@ -4754,9 +4724,7 @@ mod tests {
|
||||
let row = overlay.y + overlay.height - 1;
|
||||
|
||||
(overlay.x..overlay.x + overlay.width - 1)
|
||||
.find(|x| {
|
||||
buffer[(*x, row)].symbol() == "p" && buffer[(x + 1, row)].symbol() == "g"
|
||||
})
|
||||
.find(|x| buffer[(*x, row)].symbol() == "p" && buffer[(x + 1, row)].symbol() == "g")
|
||||
.map(|x| buffer[(x, row)].fg)
|
||||
}
|
||||
|
||||
@@ -4783,6 +4751,4 @@ mod tests {
|
||||
|
||||
std::fs::remove_dir_all(&dir).ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user