]> source.dussan.org Git - tigervnc.git/commitdiff
Move recent server to top of history
authorPierre Ossman <ossman@cendio.se>
Fri, 6 Sep 2024 14:30:02 +0000 (16:30 +0200)
committerPierre Ossman <ossman@cendio.se>
Fri, 6 Sep 2024 14:30:02 +0000 (16:30 +0200)
It's easier for the user if the most recently used entries are at the
top.

vncviewer/ServerDialog.cxx

index c5db8e1af0471db1295b89093081c11717d8ba97..d1d4bdf82b588dd4034df8ad3dfd850448c8b983 100644 (file)
@@ -292,13 +292,12 @@ void ServerDialog::handleConnect(Fl_Widget* /*widget*/, void *data)
              e.str());
   }
 
+  // avoid duplicates in the history
+  dialog->serverHistory.remove(servername);
+  dialog->serverHistory.insert(dialog->serverHistory.begin(), servername);
+
   try {
-    list<string>::iterator elem = std::find(dialog->serverHistory.begin(), dialog->serverHistory.end(), servername);
-    // avoid duplicates in the history
-    if(dialog->serverHistory.end() == elem) {
-      dialog->serverHistory.insert(dialog->serverHistory.begin(), servername);
-      dialog->saveServerHistory();
-    }
+    dialog->saveServerHistory();
   } catch (Exception& e) {
     vlog.error("%s", e.str());
     fl_alert(_("Unable to save the server history:\n\n%s"),