diff --git a/builtins/src/main/java/org/jline/builtins/Widgets.java b/builtins/src/main/java/org/jline/builtins/Widgets.java index ea9d3b2c3..ec9009901 100644 --- a/builtins/src/main/java/org/jline/builtins/Widgets.java +++ b/builtins/src/main/java/org/jline/builtins/Widgets.java @@ -50,6 +50,7 @@ public static class AutopairWidgets { private static final Map LBOUNDS; private static final Map RBOUNDS; private final Map pairs; + private final Map defaultBindings = new HashMap<>(); private final LineReaderImpl reader; private boolean autopair = false; { @@ -92,6 +93,15 @@ public AutopairWidgets(LineReader reader, boolean addCurlyBrackets) { addWidget(reader.getWidgets(), "autopair-insert", this::autopairInsert); addWidget(reader.getWidgets(), "autopair-close", this::autopairClose); addWidget(reader.getWidgets(), "autopair-delete", this::autopairDelete); + + KeyMap map = reader.getKeyMaps().get(LineReader.MAIN); + for (Map.Entry p: pairs.entrySet()) { + defaultBindings.put(p.getKey(), map.getBound(p.getKey())); + if (!p.getKey().equals(p.getValue())) { + defaultBindings.put(p.getValue(), map.getBound(p.getValue())); + } + } + defaultBindings.put(del(), map.getBound(del())); } /* @@ -167,12 +177,12 @@ private void defaultBindings() { } KeyMap map = reader.getKeyMaps().get(LineReader.MAIN); for (Map.Entry p: pairs.entrySet()) { - map.bind(new Reference(LineReader.SELF_INSERT), p.getKey()); - if (p.getKey().equals(p.getValue())) { - map.bind(new Reference(LineReader.SELF_INSERT), p.getValue()); + map.bind(defaultBindings.get(p.getKey()), p.getKey()); + if (!p.getKey().equals(p.getValue())) { + map.bind(defaultBindings.get(p.getValue()), p.getValue()); } } - map.bind(new Reference(LineReader.BACKWARD_DELETE_CHAR), del()); + map.bind(defaultBindings.get(del()), del()); autopair = false; } /*