[nemiver/console] Factorize the code



commit ecffaa44a03c856d006c41cf1bb49c4fb4f14f02
Author: Fabien Parent <parent f gmail com>
Date:   Fri Mar 2 19:36:04 2012 +0100

    Factorize the code

 src/common/nmv-console.cc |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/common/nmv-console.cc b/src/common/nmv-console.cc
index 6233073..ae17645 100644
--- a/src/common/nmv-console.cc
+++ b/src/common/nmv-console.cc
@@ -199,19 +199,19 @@ struct Console::Priv {
             }
         }
 
-        if (matches.size () == 1) {
-            std::string completion =
-                matches[0]->name ().substr (a_line.size ());
-            do_completion (completion);
-        } else if (matches.size () > 1) {
+        if (!matches.size ()) {
+            return;
+        }
+
+        std::string completion = matches[0]->name ().substr (a_line.size ());
+        if (matches.size () > 1) {
             std::string msg;
-            std::string completion =
-                matches[0]->name ().substr (a_line.size ());
             for (size_t i = 0; i < matches.size (); i++) {
                 size_t j = a_line.size ();
-                for (; j < matches[i]->name ().size ()
-                            && j < completion.size ()
-                            && matches[i]->name ()[j] == completion[j];
+                for (;
+                     j < matches[i]->name ().size ()
+                        && j < completion.size ()
+                        && matches[i]->name ()[j] == completion[j];
                      j++) {
                 }
                 completion = completion.substr (0, j);
@@ -219,8 +219,8 @@ struct Console::Priv {
             }
 
             display_message (msg);
-            do_completion (completion);
         }
+        do_completion (completion);
     }
 
     void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]