diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-27 14:10:06 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-27 14:25:36 +0000 |
| commit | b4eb83de8637b56d7d742f5e64bda454ef8c2410 (patch) | |
| tree | dcd35329c2d31b0fa2b3d733b0b874a263f39a8b /src/lib/cli_interactor.rs | |
| parent | bccac9db18b93a08e5087578231ca9ac0df1903c (diff) | |
fix: deselected items re-appear as selected when adding new item
Sync the defaults vector to the user's actual selections after each
prompt in multi_select_with_custom_value, so deselected items are not
shown as checked on the next loop iteration.
Diffstat (limited to 'src/lib/cli_interactor.rs')
| -rw-r--r-- | src/lib/cli_interactor.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/cli_interactor.rs b/src/lib/cli_interactor.rs index 97f99e8..cfb41f0 100644 --- a/src/lib/cli_interactor.rs +++ b/src/lib/cli_interactor.rs | |||
| @@ -420,8 +420,12 @@ where | |||
| 420 | .with_defaults(current_defaults), | 420 | .with_defaults(current_defaults), |
| 421 | )?; | 421 | )?; |
| 422 | 422 | ||
| 423 | // Collect selected choices | 423 | // Collect selected choices and update defaults to reflect the user's actual |
| 424 | // selections | ||
| 424 | selected_choices.clear(); // Clear previous selections to update | 425 | selected_choices.clear(); // Clear previous selections to update |
| 426 | for (i, default) in defaults.iter_mut().enumerate() { | ||
| 427 | *default = selected_indices.contains(&i); | ||
| 428 | } | ||
| 425 | for &index in &selected_indices { | 429 | for &index in &selected_indices { |
| 426 | if index < choices.len() { | 430 | if index < choices.len() { |
| 427 | // Exclude 'add another' option | 431 | // Exclude 'add another' option |