]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: fix interface sorting
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 19 Oct 2023 12:19:06 +0000 (14:19 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 19 Oct 2023 12:19:06 +0000 (14:19 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxmox-tui-installer/src/main.rs

index c3c21c3f1f3ac0bd4b5d420b887f0e862a2ccaf6..0a61e39d19fb836fee621a8b80c5ddb15e923575 100644 (file)
@@ -552,20 +552,18 @@ fn network_dialog(siv: &mut Cursive) -> InstallerView {
     let ifnames = ifaces
         .clone()
         .map(|iface| (iface.render(), iface.name.clone()));
+    let mut ifaces_selection = SelectView::new().popup().with_all(ifnames.clone());
+
+    ifaces_selection.sort();
+    ifaces_selection.set_selection(
+        ifnames
+            .clone()
+            .position(|iface| &iface.1 == &options.ifname)
+            .unwrap_or(ifaces.len() - 1),
+    );
 
     let inner = FormView::new()
-        .child(
-            "Management interface",
-            SelectView::new()
-                .popup()
-                .with_all(ifnames.clone())
-                .selected(
-                    ifaces
-                        .clone()
-                        .position(|iface| &iface.name == &options.ifname)
-                        .unwrap_or_default(),
-                ),
-        )
+        .child("Management interface", ifaces_selection)
         .child(
             "Hostname (FQDN)",
             EditView::new().content(options.fqdn.to_string()),