karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [karaf] branch master updated: [KARAF-5665] Sometimes the command description does not show when listing commands with "TAB"
Date Tue, 13 Mar 2018 07:11:48 GMT
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new 801745b  [KARAF-5665] Sometimes the command description does not show when listing
commands with "TAB"
801745b is described below

commit 801745b1faf758e73480212c3d4ec74d2e1b372e
Author: Guillaume Nodet <gnodet@gmail.com>
AuthorDate: Tue Mar 13 08:11:30 2018 +0100

    [KARAF-5665] Sometimes the command description does not show when listing commands with
"TAB"
---
 .../karaf/shell/impl/console/ConsoleSessionImpl.java  | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index 075c10a..12c5519 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -66,14 +66,7 @@ import org.apache.karaf.shell.support.completers.FileOrUriCompleter;
 import org.apache.karaf.shell.support.completers.UriCompleter;
 import org.apache.karaf.util.filesstream.FilesStream;
 import org.jline.builtins.Completers;
-import org.jline.reader.Completer;
-import org.jline.reader.EndOfFileException;
-import org.jline.reader.LineReader;
-import org.jline.reader.LineReaderBuilder;
-import org.jline.reader.MaskingCallback;
-import org.jline.reader.ParsedLine;
-import org.jline.reader.SyntaxError;
-import org.jline.reader.UserInterruptException;
+import org.jline.reader.*;
 import org.jline.terminal.Terminal.Signal;
 import org.jline.terminal.impl.DumbTerminal;
 import org.osgi.service.event.EventAdmin;
@@ -166,6 +159,7 @@ public class ConsoleSessionImpl implements Session {
         Completer completer =  (rdr, line, candidates) -> {
             builtinCompleter.complete(rdr, line, candidates);
             commandsCompleter.complete(rdr, line, candidates);
+            merge(candidates);
         };
 
         // Masking
@@ -237,6 +231,15 @@ public class ConsoleSessionImpl implements Session {
 
     }
 
+    private void merge(List<Candidate> candidates) {
+        Map<String, Candidate> map = new HashMap<>();
+        for (Candidate c : candidates) {
+            map.merge(c.value(), c, (c1, c2) -> c1.descr() != null ? c1 : c2);
+        }
+        candidates.clear();
+        candidates.addAll(map.values());
+    }
+
     private Completer createBuiltinCompleter() {
         Completers.CompletionEnvironment env = new Completers.CompletionEnvironment() {
             @Override

-- 
To stop receiving notification emails like this one, please contact
gnodet@apache.org.

Mime
View raw message