--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java Thu Nov 02 04:36:53 2017 -0400
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java Thu Nov 02 10:09:34 2017 +0100
@@ -237,7 +237,11 @@
.distinct()
.count() == 2;
boolean tooManyItems = suggestions.size() > in.getAutoprintThreshold();
- CompletionTask ordinaryCompletion = new OrdinaryCompletionTask(suggestions, anchor[0], !command && !doc.isEmpty(), hasSmart);
+ CompletionTask ordinaryCompletion =
+ new OrdinaryCompletionTask(suggestions,
+ anchor[0],
+ !command && !doc.isEmpty(),
+ hasBoth);
CompletionTask allCompletion = new AllSuggestionsCompletionTask(suggestions, anchor[0]);
todo = new ArrayList<>();
@@ -439,16 +443,16 @@
private final List<Suggestion> suggestions;
private final int anchor;
private final boolean cont;
- private final boolean smart;
+ private final boolean showSmart;
public OrdinaryCompletionTask(List<Suggestion> suggestions,
int anchor,
boolean cont,
- boolean smart) {
+ boolean showSmart) {
this.suggestions = suggestions;
this.anchor = anchor;
this.cont = cont;
- this.smart = smart;
+ this.showSmart = showSmart;
}
@Override
@@ -460,7 +464,7 @@
public Result perform(String text, int cursor) throws IOException {
List<CharSequence> toShow;
- if (smart) {
+ if (showSmart) {
toShow =
suggestions.stream()
.filter(Suggestion::matchesType)
@@ -487,7 +491,7 @@
String prefixStr = prefix.orElse("").substring(cursor - anchor);
in.putString(prefixStr);
- boolean showItems = toShow.size() > 1 || smart;
+ boolean showItems = toShow.size() > 1 || showSmart;
if (showItems) {
in.println();
@@ -495,7 +499,7 @@
}
if (!prefixStr.isEmpty())
- return showItems ? Result.SKIP : Result.SKIP_NOREPAINT;
+ return showItems ? Result.FINISH : Result.SKIP_NOREPAINT;
return cont ? Result.CONTINUE : Result.FINISH;
}
--- a/test/langtools/jdk/jshell/ToolTabCommandTest.java Thu Nov 02 04:36:53 2017 -0400
+++ b/test/langtools/jdk/jshell/ToolTabCommandTest.java Thu Nov 02 10:09:34 2017 +0100
@@ -84,10 +84,6 @@
inputSink.write("\u0003/env \011");
waitOutput(out, "\u0005/env -\n" +
"-add-exports -add-modules -class-path -module-path \n" +
- "\r\u0005/env -");
-
- inputSink.write("\011");
- waitOutput(out, "-add-exports -add-modules -class-path -module-path \n" +
"\n" +
Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
"\r\u0005/env -");
--- a/test/langtools/jdk/jshell/ToolTabSnippetTest.java Thu Nov 02 04:36:53 2017 -0400
+++ b/test/langtools/jdk/jshell/ToolTabSnippetTest.java Thu Nov 02 10:09:34 2017 +0100
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 8177076 8185426
+ * @bug 8177076 8185426 8189595
* @modules
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -227,6 +227,31 @@
});
}
+ public void testNoRepeat() throws Exception {
+ doRunTest((inputSink, out) -> {
+ inputSink.write("String xyzAA;\n");
+ waitOutput(out, "\u0005");
+
+ //xyz<tab>
+ inputSink.write("String s = xyz\011");
+ waitOutput(out, "^String s = xyzAA");
+ inputSink.write(".");
+ waitOutput(out, "^\\.");
+
+ inputSink.write("\u0003");
+ waitOutput(out, "\u0005");
+
+ inputSink.write("double xyzAB;\n");
+ waitOutput(out, "\u0005");
+
+ //xyz<tab>
+ inputSink.write("String s = xyz\011");
+ String allCompletions =
+ Pattern.quote(getResource("jshell.console.completion.all.completions"));
+ waitOutput(out, ".*xyzAA.*" + allCompletions + ".*\u0005String s = xyzA");
+ });
+ }
+
private Path prepareZip() {
String clazz1 =
"package jshelltest;\n" +