Skip to content

Commit

Permalink
Navigating grouped candidates using arrow keys is broken, fixes #580
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Sep 25, 2020
1 parent d386045 commit 22faa8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
15 changes: 1 addition & 14 deletions demo/src/main/scripts/init.jline
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _testWidget() {
#
def _tailTipToggle() {
def al = _reader.getWidgets().get('accept-line').toString()
def enabled = al == '_tailtip-accept-line' ? true : false
def enabled = al == '_tailtip-accept-line'
if (enabled) {
_reader.setVariable('LIST_MAX',100)
_reader.option(org.jline.reader.LineReader.Option.INSERT_BRACKET, true)
Expand All @@ -133,18 +133,6 @@ def _docJline() {
def _docGroovy() {
:doc groovy
}
#
# widget function to toggle candidate grouping
#
def _toggleGroup(){
if (_reader.isSet(org.jline.reader.LineReader.Option.AUTO_GROUP)) {
:setopt no-group
:setopt no-auto-group
} else {
:unsetopt no-group
:unsetopt no-auto-group
}
}

#
# resolve function keys
Expand All @@ -161,7 +149,6 @@ widget -N _test-widget _testWidget
widget -N _tailtip-toggle _tailTipToggle
widget -N _doc-jline _docJline
widget -N _doc-groovy _docGroovy
widget -N _toggle-group _toggleGroup

keymap '^[^x' _test-widget
keymap '^[s' _tailtip-toggle
Expand Down
10 changes: 9 additions & 1 deletion reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4903,7 +4903,11 @@ protected boolean doMenu(List<Candidate> original, String completed, BiFunction<
original.sort(getCandidateComparator(caseInsensitive, completed));
mergeCandidates(original);
computePost(original, null, possible, completed);

// candidate grouping is not supported by MenuSupport
boolean defaultAutoGroup = isSet(Option.AUTO_GROUP);
boolean defaultGroup = isSet(Option.GROUP);
option(Option.AUTO_GROUP, false);
option(Option.GROUP, false);
// Build menu support
MenuSupport menuSupport = new MenuSupport(original, completed, escaper);
post = menuSupport;
Expand Down Expand Up @@ -4960,12 +4964,16 @@ && getLastBinding().charAt(0) != ' '
pushBackBinding(true);
}
post = null;
option(Option.AUTO_GROUP, defaultAutoGroup);
option(Option.GROUP, defaultGroup);
return true;
}
}
doAutosuggestion = false;
callWidget(REDISPLAY);
}
option(Option.AUTO_GROUP, defaultAutoGroup);
option(Option.GROUP, defaultGroup);
return false;
}

Expand Down

0 comments on commit 22faa8b

Please sign in to comment.