Skip to content

Commit

Permalink
Widgets: executeWidget() restore old binding after runMacro()
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed May 3, 2020
1 parent bf7f1ad commit 9613ec3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions builtins/src/main/java/org/jline/builtins/Widgets.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ public void callWidget(String name) {
* @param name widget name
*/
public void executeWidget(String name) {
// WORK-AROUND
Binding ref = getKeyMap().getBoundKeys().get(alt(ctrl('X')));
getKeyMap().bind(new Reference(name), alt(ctrl('X')));
reader.runMacro(alt(ctrl('X')));
// The line below should be executed inside readLine()!!!
// Create LineReader method executeWidget() maybe???
//
// widget(name).apply();
if (ref != null) {
getKeyMap().bind(ref, alt(ctrl('X')));
}
}

/**
Expand Down Expand Up @@ -300,11 +299,9 @@ public void initDescription(int size) {
as.add(new AttributedString(""));
}
addDescription(as);
executeWidget(LineReader.REDRAW_LINE);
} else if (status != null) {
if (size < 0) {
status.update(null);
executeWidget(LineReader.REDRAW_LINE);
} else {
status.clear();
}
Expand Down Expand Up @@ -1054,6 +1051,7 @@ public boolean toggleWindow() {
} else {
destroyDescription();
}
callWidget(LineReader.REDRAW_LINE);
return true;
}

Expand All @@ -1067,6 +1065,7 @@ public boolean toggleKeyBindings() {
initDescription(descriptionSize);
}
}
callWidget(LineReader.REDRAW_LINE);
return enabled;
}

Expand Down

0 comments on commit 9613ec3

Please # to comment.