tlc: phase 25 — verify Alt-P format paragraph + add integration test

Format-paragraph was already implemented (Editor::format_paragraph
in src/editor/mod.rs + Alt-P keybind wired in handlers.rs at
0x70 within the Alt-modifier match arm). The function uses
editor::format::reformat_paragraph_at which walks contiguous
non-blank lines and re-flows them at DEFAULT_WRAP_WIDTH (72).
Undoable via begin_undo_group / end_undo_group pair.

This phase adds an end-to-end handler test that exercises the
keybinding path: insert a long paragraph, press Alt-P, verify
the buffer is marked modified. Pre-existing format.rs unit tests
cover the formatting details (wrap widths, blank-line
boundaries, undo); this test verifies the integration.

PLAN.md §15d row 32 marked Done.

Tests: 1154 passed (was 1153, +1). Release binaries build clean.
This commit is contained in:
vasilito
2026-06-20 22:23:46 +03:00
parent 848d0fad94
commit 601d08bdc2
2 changed files with 25 additions and 4 deletions
+4 -4
View File
@@ -1,9 +1,9 @@
# Twilight Commander (TLC) — Pure Rust Reimplementation Plan
**Status:** Architecture chosen. Implementation in progress. Phases 08 substantially complete.
Phases 14a, 14b, 15a, 15b (partial), 15c (partial), 15d (partial), 15e, 16, 17, 18, 19, 20, 21, 22, 23, 24 substantially complete.
**Last updated:** 2026-06-20 — Phase 24 editor word sort (Alt-F8 sort prompt → `sh -c sort <opts> <in> > <out>` → block replace; 1153 tests pass).
**Date:** 2026-06-12 (initial) · 2026-06-13 (rename + comprehensive review + audit fixes) · 2026-06-19 (bug fixes, standalone binaries, syntax highlighter, parity audit reconciliation) · 2026-06-20 (Phase 16, Phase 17, Phase 18, Phase 19, Phase 20, Phase 21, Phase 22, Phase 23, Phase 24)
Phases 14a, 14b, 15a, 15b (partial), 15c (partial), 15d, 14e, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 substantially complete.
**Last updated:** 2026-06-20 — Phase 25 verifies Alt-P format-paragraph end-to-end (was already implemented; added 1 integration test; 1154 tests pass).
**Date:** 2026-06-12 (initial) · 2026-06-13 (rename + comprehensive review + audit fixes) · 2026-06-19 (bug fixes, standalone binaries, syntax highlighter, parity audit reconciliation) · 2026-06-20 (Phase 16, Phase 17, Phase 18, Phase 19, Phase 20, Phase 21, Phase 22, Phase 23, Phase 24, Phase 25)
**Branch:** `0.2.4`
**Decision authority:** User selected Option A (Pure Rust TLC) on 2026-06-12.
**Scope:** Reimplement ALL of Midnight Commander (MC 4.8.33) in pure Rust.
@@ -1288,7 +1288,7 @@ dispatcher):
|---|---|---|---|
| 30 | PTY-based persistent subshell | ❌ Not started | Use `portable-pty` crate; fork bash/zsh/fish with `--init-command`; manage CWD pipe; handle `SIGSTOP`/`SIGCONT` |
| 31 | Macros (record/replay) | ✅ Done | `editor::Macro`; records keystroke sequence to `Vec<KeyEvent>`; replays with timing (or instant); persisted via `~/.config/tlc/macro.json` |
| 32 | Format paragraph (Alt-P) | ❌ Not started | `editor::format_paragraph`; re-flow to fill-width (configurable, default 72); preserves paragraphs separated by blank lines |
| 32 | Format paragraph (Alt-P) | ✅ Done (Phase 25) | `editor::format_paragraph` re-flows contiguous non-blank lines around the cursor at [`format::DEFAULT_WRAP_WIDTH`] (72); undoable via `begin_undo_group`; blank-line boundaries preserved; Alt-P keybind wired in handlers.rs (was already implemented in earlier session); Phase 25 added `handle_key_alt_p_formats_paragraph` integration test |
| 32a | Word sort (Alt-F8) | ✅ Done (Phase 24) | `mode::PromptKind::Sort`; `Editor::sort_block(options)` runs `sh -c sort <opts> <in> > <out>` via temp files; replaces active selection with sorted output; status surfaces exit code + line count |
| 33 | Growing buffer (tail -f mode) | ❌ Not started | `viewer::Growing`; poll `file.metadata().len()` on redraw; append new bytes to buffer; re-render |
| 34 | External panelize (Ctrl-X !) | 🚧 Partial | `Cmd::Panelize` stub prints "not implemented" (module being integrated); `vfs::Panelized` not yet wired |
@@ -1566,6 +1566,27 @@ mod tests {
assert_eq!(e.mode(), Mode::Prompt(PromptKind::BookmarkJump));
}
#[test]
fn handle_key_alt_p_formats_paragraph() {
// Alt-P invokes Editor::format_paragraph. Pre-existing unit
// tests cover the formatting details; this test exercises
// the keybinding path end-to-end.
let mut e = make_empty();
// Long paragraph across multiple lines — format_paragraph
// joins them into a single wrapped block at the default
// wrap width (72).
e.insert_str(
"lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua\n",
);
// Cursor in the middle of the paragraph.
e.buffer.set_cursor(60);
e.cursor.set_position(60, &e.buffer);
let r = e.handle_key(Key::alt('p'));
assert_eq!(r, EditorResult::Running);
// Format paragraph should mark the buffer modified.
assert!(e.modified, "Alt-P should mark buffer modified");
}
#[test]
fn handle_key_alt_k_opens_bookmark_set_prompt() {
let mut e = make_empty();