max / alloy
1 file changed,
+36 insertions,
-0 deletions
| @@ -3527,6 +3527,18 @@ | |||
| 3527 | 3527 | }; | |
| 3528 | 3528 | match rule.resolve(&self.disks) { | |
| 3529 | 3529 | Ok(path) => { | |
| 3530 | + | // Put the cursor on the disk the rule named, so a user | |
| 3531 | + | // who steps back into this screen finds the row that | |
| 3532 | + | // was chosen for them selected. Nothing downstream | |
| 3533 | + | // reads the cursor -- the plan and the erase modal both | |
| 3534 | + | // take `answers.disk` -- so this is about what the | |
| 3535 | + | // screen says rather than about what gets erased. | |
| 3536 | + | if let (Some(at), Some(now)) = ( | |
| 3537 | + | self.disks.iter().position(|d| d.path == path), | |
| 3538 | + | self.cursor.selected(), | |
| 3539 | + | ) { | |
| 3540 | + | self.cursor.move_by(at as isize - now as isize); | |
| 3541 | + | } | |
| 3530 | 3542 | self.answers.disk = Some(path); | |
| 3531 | 3543 | self.from_medium.disk = true; | |
| 3532 | 3544 | true | |
| @@ -5764,6 +5776,30 @@ | |||
| 5764 | 5776 | assert_eq!(view.answers.disk, None); | |
| 5765 | 5777 | } | |
| 5766 | 5778 | ||
| 5779 | + | /// Stepping back into the skipped disk step shows the disk that was chosen. | |
| 5780 | + | #[test] | |
| 5781 | + | fn the_skipped_disk_step_comes_back_with_its_disk_selected() { | |
| 5782 | + | let mut sheet = fw12_sheet(); | |
| 5783 | + | sheet.disk = Some(DiskRule::SingleInternal); | |
| 5784 | + | let view = preseeded( | |
| 5785 | + | sheet, | |
| 5786 | + | vec![ | |
| 5787 | + | { | |
| 5788 | + | let mut stick = target("sdb", Some("usb")); | |
| 5789 | + | stick.removable = true; | |
| 5790 | + | stick | |
| 5791 | + | }, | |
| 5792 | + | target("nvme0n1", Some("nvme")), | |
| 5793 | + | ], | |
| 5794 | + | ); | |
| 5795 | + | assert_eq!(view.answers.disk.as_deref(), Some("/dev/nvme0n1")); | |
| 5796 | + | assert_eq!( | |
| 5797 | + | view.selected().map(|d| d.path.as_str()), | |
| 5798 | + | Some("/dev/nvme0n1"), | |
| 5799 | + | "the cursor was left on a disk the rule did not choose", | |
| 5800 | + | ); | |
| 5801 | + | } | |
| 5802 | + | ||
| 5767 | 5803 | /// A prefilled answer stays correctable, which is what makes prefilling | |
| 5768 | 5804 | /// safe to do at all. | |
| 5769 | 5805 | #[test] |