Skip to content

Commit cdef186

Browse files
committed
8232856: jshell crashes when pressing up arrow after /!
Reviewed-by: psandoz
1 parent 700447f commit cdef186

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ public void replaceLastHistoryEntry(String source) {
833833
}
834834
it.remove();
835835
in.getHistory().add(source);
836+
in.getHistory().resetIndex();
836837
}
837838

838839
private static final long ESCAPE_TIMEOUT = 100;

test/langtools/jdk/jshell/HistoryUITest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* @test
26-
* @bug 8178077
26+
* @bug 8178077 8232856
2727
* @summary Check the UI behavior of editing history.
2828
* @modules
2929
* jdk.compiler/com.sun.tools.javac.api
@@ -77,4 +77,16 @@ public void testPrevNextSnippet() throws Exception {
7777
});
7878
}
7979

80+
public void testReRun() throws Exception {
81+
doRunTest((inputSink, out) -> {
82+
inputSink.write("System.err.println(\"RAN\");\n");
83+
waitOutput(out, "RAN.*" + PROMPT);
84+
inputSink.write("/!\n");
85+
waitOutput(out, "RAN.*" + PROMPT);
86+
inputSink.write(UP);
87+
inputSink.write("\n");
88+
waitOutput(out, "RAN.*" + PROMPT);
89+
});
90+
}
91+
8092
}

0 commit comments

Comments
 (0)