From c1f4ebf5fc9501662e367d608b9fa31c2ed91ec7 Mon Sep 17 00:00:00 2001 From: Ed L Date: Tue, 24 Mar 2026 11:40:55 -0700 Subject: [PATCH] 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 --- src/ui/app.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ui/app.rs b/src/ui/app.rs index f819dd3..6fdd10a 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -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"); + } }