mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8189595: jshell tool: line redrawn on each completion
Reviewed-by: rfield
This commit is contained in:
parent
2c28613ce4
commit
e44c7feff9
@ -237,7 +237,11 @@ class ConsoleIOContext extends IOContext {
|
||||
.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 @@ class ConsoleIOContext extends IOContext {
|
||||
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 @@ class ConsoleIOContext extends IOContext {
|
||||
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 @@ class ConsoleIOContext extends IOContext {
|
||||
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 @@ class ConsoleIOContext extends IOContext {
|
||||
}
|
||||
|
||||
if (!prefixStr.isEmpty())
|
||||
return showItems ? Result.SKIP : Result.SKIP_NOREPAINT;
|
||||
return showItems ? Result.FINISH : Result.SKIP_NOREPAINT;
|
||||
|
||||
return cont ? Result.CONTINUE : Result.FINISH;
|
||||
}
|
||||
|
||||
@ -84,10 +84,6 @@ public class ToolTabCommandTest extends UITesting {
|
||||
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 -");
|
||||
|
||||
@ -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 class ToolTabSnippetTest extends UITesting {
|
||||
});
|
||||
}
|
||||
|
||||
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" +
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user