Merge branch 'main' into worktree-improvise-ewi-formula-crate
# Conflicts: # TAGS
This commit is contained in:
@ -118,6 +118,35 @@ mod tests {
|
||||
assert!(effects.is_empty());
|
||||
}
|
||||
|
||||
/// `CommitAndAdvance` must thread its `edit_mode` through to the
|
||||
/// trailing `EnterEditAtCursor` effect so the post-commit re-edit lands
|
||||
/// in the mode the keymap requested. The command never reads ctx.mode.
|
||||
#[test]
|
||||
fn commit_and_advance_threads_edit_mode_to_enter_edit_at_cursor() {
|
||||
let m = two_cat_model();
|
||||
let layout = make_layout(&m);
|
||||
let reg = make_registry();
|
||||
let mut bufs = HashMap::new();
|
||||
bufs.insert("edit".to_string(), "42".to_string());
|
||||
let mut ctx = make_ctx(&m, &layout, ®);
|
||||
ctx.buffers = &bufs;
|
||||
// ctx.mode stays Normal — the command must not look at it.
|
||||
let key = ctx.cell_key().unwrap();
|
||||
let cmd = CommitAndAdvance {
|
||||
key,
|
||||
value: "42".to_string(),
|
||||
advance: super::AdvanceDir::Down,
|
||||
cursor: super::CursorState::from_ctx(&ctx),
|
||||
edit_mode: AppMode::records_editing(),
|
||||
};
|
||||
let effects = cmd.execute(&ctx);
|
||||
let dbg = effects_debug(&effects);
|
||||
assert!(
|
||||
dbg.contains("EnterEditAtCursor") && dbg.contains("RecordsEditing"),
|
||||
"Expected trailing EnterEditAtCursor with RecordsEditing target, got: {dbg}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commit_export_produces_export_and_normal_mode() {
|
||||
let m = two_cat_model();
|
||||
@ -234,12 +263,18 @@ pub enum AdvanceDir {
|
||||
|
||||
/// Commit a cell edit, advance the cursor, and re-enter edit mode.
|
||||
/// Subsumes the old `CommitCellEdit` (Down) and `CommitAndAdvanceRight` (Right).
|
||||
///
|
||||
/// `edit_mode` is the editing mode to re-enter after advancing. The keymap
|
||||
/// binding supplies this — the editing-mode keymap passes `editing` and the
|
||||
/// records-editing keymap passes `records-editing`. The command itself
|
||||
/// never inspects `ctx.mode`.
|
||||
#[derive(Debug)]
|
||||
pub struct CommitAndAdvance {
|
||||
pub key: CellKey,
|
||||
pub value: String,
|
||||
pub advance: AdvanceDir,
|
||||
pub cursor: CursorState,
|
||||
pub edit_mode: AppMode,
|
||||
}
|
||||
impl Cmd for CommitAndAdvance {
|
||||
fn name(&self) -> &'static str {
|
||||
@ -287,7 +322,9 @@ impl Cmd for CommitAndAdvance {
|
||||
}
|
||||
}
|
||||
}
|
||||
effects.push(Box::new(effect::EnterEditAtCursor));
|
||||
effects.push(Box::new(effect::EnterEditAtCursor {
|
||||
target_mode: self.edit_mode.clone(),
|
||||
}));
|
||||
effects
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user