RFR: JDK-8178821: jshell tool: ctrl-down does nothing in current context
Jan Lahoda
jan.lahoda at oracle.com
Wed Apr 19 20:08:07 UTC 2017
Bug:
https://bugs.openjdk.java.net/browse/JDK-8178821
Webrev:
http://cr.openjdk.java.net/~jlahoda/8178821/webrev.00/
The problem here is as follows: for JShell and jjs, we wrap the class
that provides input history (jline's MemoryHistory) with our own custom
version, that has an extra feature to simplify editing of code snippets
(code snippet may be a multi-line method, for example).
For this feature, there are two actions: go to the previous/next code
snippet. These actions are implemented using MemoryHistory.index()
[which returns the index of the currently selected history entry] and
.size() [which returns the number of history entries].
The MemoryHistory has a limit on number of entries in it (500 by
default). So, the .size() will be 500 at most. But, when the oldest
entries are removed, the index() of the retained entries will not
change, and so index() may go beyond 500. Also, as a consequence, the
first retained entry does not necessarily have index() == 0.
The two effects this has are:
-Ctrl-down sometimes does not work as the current nextSnippet method
won't work if index() [of the current entry] >= size()
-Ctrl-up may crash with an exception if inspecting entries that have
been removed, as Ctrl-up currently runs as long as index() >= 0
The proposed patch is to reuse existing previous()/next() methods, which
select previous/next history entry, and check the entry index against
size correctly.
Thanks,
Jan
More information about the kulla-dev
mailing list