diff --git a/src/org/ringojs/tools/RingoShell.java b/src/org/ringojs/tools/RingoShell.java index 4dc8046b..2cc43509 100644 --- a/src/org/ringojs/tools/RingoShell.java +++ b/src/org/ringojs/tools/RingoShell.java @@ -23,8 +23,6 @@ import org.jline.reader.impl.history.DefaultHistory; import org.jline.terminal.Terminal; import org.jline.terminal.TerminalBuilder; -import org.jline.utils.AttributedStringBuilder; -import org.jline.utils.AttributedStyle; import org.ringojs.engine.ModuleScope; import org.ringojs.engine.ReloadableScript; import org.ringojs.engine.RhinoEngine; @@ -239,11 +237,12 @@ class JSCompleter implements Completer { @Override public void complete(LineReader lineReader, ParsedLine parsedLine, List list) { try { - Matcher match = variables.matcher(parsedLine.line()); + String line = parsedLine.line(); + Matcher match = variables.matcher(line); if (match.find()) { - String word = match.group(2); + String path = match.group(2); Scriptable obj = scope; - String[] parts = word.split("\\.", -1); + String[] parts = path.split("\\.", -1); for (int k = 0; k < parts.length - 1; k++) { Object o = ScriptableObject.getProperty(obj, parts[k]); if (o == null || o == ScriptableObject.NOT_FOUND) { @@ -251,15 +250,16 @@ public void complete(LineReader lineReader, ParsedLine parsedLine, List list) { + private void collectIds(Object[] ids, Scriptable obj, String line, String lastPart, List list) { for (Object id: ids) { if (!(id instanceof String)) { continue; } String str = (String) id; - if (str.startsWith(lastpart) || word.endsWith(".")) { + if (str.startsWith(lastPart)) { if (ScriptableObject.getProperty(obj, str) instanceof Callable) { str += "("; } - String suffix = str.substring(lastpart.length()); - AttributedStringBuilder sb = new AttributedStringBuilder(); - sb.styled(AttributedStyle.DEFAULT.foreground(AttributedStyle.CYAN), lastpart); - sb.styled(AttributedStyle.DEFAULT, suffix); - list.add(new Candidate(word + suffix, - sb.toAnsi(terminal), null, null, null, null, false)); + Candidate candidate = new Candidate(line + str, line + str, null, null, null, null, false); + list.add(candidate); } } } @@ -299,28 +295,35 @@ private void collectIds(Object[] ids, Scriptable obj, String word, String lastpa "break", "case", "catch", + "const", "continue", + "debugger", "default", "delete", "do", "else", + "false", "finally", "for", "function", "if", "in", "instanceof", + "let", "new", + "null", "return", "switch", "this", "throw", + "true", "try", "typeof", "var", "void", "while", - "with" + "with", + "yield" }; }