fix: :import command now opens the wizard instead of silently closing

execute_command set mode to ImportWizard, but the caller immediately
reset it to Normal for any non-Quit mode. Added ImportWizard to the
exclusion list so the wizard survives the reset.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ed L
2026-03-24 11:40:55 -07:00
parent 1345142fe0
commit c1f4ebf5fc

View File

@ -358,7 +358,7 @@ impl App {
buffer.clone()
} else { return Ok(()); };
self.execute_command(&buf)?;
if !matches!(self.mode, AppMode::Quit) {
if !matches!(self.mode, AppMode::Quit | AppMode::ImportWizard) {
self.mode = AppMode::Normal;
}
}
@ -1197,4 +1197,25 @@ mod tests {
app.enter_advance();
assert_eq!(app.model.active_view().selected, (2, 1));
}
#[test]
fn import_command_switches_to_import_wizard_mode() {
// Regression: execute_command was resetting mode to Normal after
// :import set it to ImportWizard, so the wizard never appeared.
let mut app = two_col_model();
let json: serde_json::Value = serde_json::json!([{"cat": "A", "val": 1}]);
app.start_import_wizard(json);
assert!(matches!(app.mode, AppMode::ImportWizard),
"mode should be ImportWizard after start_import_wizard");
}
#[test]
fn execute_import_command_leaves_mode_as_import_wizard() {
let mut app = two_col_model();
// Inject JSON via start_import_wizard to simulate what :import does
app.start_import_wizard(serde_json::json!([{"x": 1}]));
// After the command the mode must NOT be reset to Normal
assert!(!matches!(app.mode, AppMode::Normal),
"mode must not be Normal after import wizard is opened");
}
}