Pin the touched reset on the editor an advance reopens (improvise-465t)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
@@ -4963,3 +4963,11 @@ the keyboard paths a trimmed comparison cannot be seen through the keys, since
|
||||
any whitespace edit also sets `touched`, so this unit test and the mouse path
|
||||
are where it shows. The mouse test now also asserts that `"7 "` against the
|
||||
seed `"7"` is a write.
|
||||
|
||||
### `resolve::tests::the_editor_an_advance_reopens_starts_untouched`
|
||||
|
||||
**improvise-465t**, the browser half. The fixture is a 3×1 grid with the cursor
|
||||
on row 1. The test presses `i`, types `9`, and asserts the first editor really
|
||||
is touched. Enter must then land on (2, 0), and the folded `opened_editor` must
|
||||
be exactly `OpenedEditor::on("800")`. **Injection:** `resolve::advanced`
|
||||
carrying the previous editor's `touched` flag. This test fails alone.
|
||||
|
||||
@@ -5827,3 +5827,18 @@ editor's seed.
|
||||
This test is only possible because `clear-buffer` and keys typed into another
|
||||
buffer do not mark the editor. A rule that marked on every buffer write would
|
||||
make the guard redundant, and no test could pin it (`protocol.md` §3).
|
||||
|
||||
### `command::cmd::commit::tests::the_editor_an_advance_reopens_starts_untouched`
|
||||
|
||||
**improvise-465t**, found by the #205 re-review. Every open resets `touched`,
|
||||
but no test pinned the reset on the editor that `CommitAndAdvance` reopens
|
||||
through `EnterEditAtCursor`. The test works on the 2×2 pivot. It presses `i`
|
||||
on (West, Cost), row 1 and column 0, types `9`, and asserts the first editor
|
||||
really is touched. Then it presses Enter. The cursor must land on (0, 1), and
|
||||
the reopened editor must be exactly `OpenedEditor::on("2")`, which means seeded
|
||||
from the landed cell and untouched.
|
||||
|
||||
**Injection:** `EnterEditAtCursor` carrying the previous editor's `touched`
|
||||
flag. This test fails alone. Every other test stays green, which was the gap.
|
||||
Once improvise-fy9o re-seeds the reopened editor, a stale `touched` would make
|
||||
every untouched Tab or Enter write its seed.
|
||||
|
||||
@@ -767,6 +767,29 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// improvise-465t: the editor an advance reopens is a new open, so it starts
|
||||
/// untouched even when the commit before it was typed. See command.md.
|
||||
#[test]
|
||||
fn the_editor_an_advance_reopens_starts_untouched() {
|
||||
use improvise_protocol::key::KeyCode;
|
||||
let mut app = grid_holding(CellValue::Number(4.0), false);
|
||||
app.cursor_mut().selected = (1, 0);
|
||||
press(&mut app, KeyCode::Char('i'));
|
||||
press(&mut app, KeyCode::Char('9'));
|
||||
assert_eq!(
|
||||
app.view_state.opened_editor.as_ref().map(|o| o.touched),
|
||||
Some(true),
|
||||
"the first editor was never touched, so this proves nothing"
|
||||
);
|
||||
press(&mut app, KeyCode::Enter);
|
||||
assert_eq!(app.cursor().selected, (0, 1), "the advance did not run");
|
||||
assert_eq!(
|
||||
app.view_state.opened_editor,
|
||||
Some(OpenedEditor::on("2".into())),
|
||||
"the reopened editor inherited the previous editor's touched flag"
|
||||
);
|
||||
}
|
||||
|
||||
/// BUG (improvise-ixxx) — see `context/test-evidence/command.md`.
|
||||
#[test]
|
||||
fn an_untouched_commit_still_advances_and_reopens_the_editor() {
|
||||
|
||||
@@ -3453,6 +3453,31 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// improvise-465t: the editor an advance reopens starts untouched, even
|
||||
/// after a typed commit. See `context/test-evidence/clients.md`.
|
||||
#[test]
|
||||
fn the_editor_an_advance_reopens_starts_untouched() {
|
||||
let mut client = client_on_row_one("7");
|
||||
press_folded(&mut client, KeyCode::Char('i'));
|
||||
press_folded(&mut client, KeyCode::Char('9'));
|
||||
assert_eq!(
|
||||
client.view.opened_editor.as_ref().map(|o| o.touched),
|
||||
Some(true),
|
||||
"the first editor was never touched, so this proves nothing"
|
||||
);
|
||||
press_folded(&mut client, KeyCode::Enter);
|
||||
assert_eq!(
|
||||
client.view.cursor().selected,
|
||||
(2, 0),
|
||||
"the advance did not run"
|
||||
);
|
||||
assert_eq!(
|
||||
client.view.opened_editor,
|
||||
Some(OpenedEditor::on("800".into())),
|
||||
"the reopened editor inherited the previous editor's touched flag"
|
||||
);
|
||||
}
|
||||
|
||||
/// BUG (improvise-2054) — see `context/test-evidence/clients.md`.
|
||||
#[test]
|
||||
fn a_browser_editor_typed_back_to_its_seed_still_writes() {
|
||||
|
||||
Reference in New Issue
Block a user