summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-01-26 23:03:36 +0100
committerRobin Jarry <robin@jarry.cc>2024-01-27 22:24:30 +0100
commit64d76e32d1d4db0f9512a71c2896253f23eb3c06 (patch)
tree504738199bfd5a7616bc28c633eb5c76dc792743
parent1aa1f46a2cb8cdc62eeaf520870fc3de3d3eed25 (diff)
downloadaerc-64d76e32d1d4db0f9512a71c2896253f23eb3c06.tar.gz
aerc-64d76e32d1d4db0f9512a71c2896253f23eb3c06.zip
bindings: do not systematically trigger completion
When simulating keystrokes of a binding, the command completion is disabled momentarily for performance reasons and re-enabled once the sequence is finished. See commit 055c6dc6604f ("exline: don't draw completions for keybinds") for more details. Since commit 0b0095eeadaf ("complete: allow disabling automatic completion"), it is possible to only rely on explicit keystrokes to display the completion menu. With the default settings, if a key sequence contains more than [ui].completion-min-chars, it should trigger completion after [ui].completion-delay. But since the completion was disabled when the keystrokes are input, it does not trigger the completion. To work around this, an artificial <Tab> keystroke was added at the end of the sequence to force trigger the completion menu. For more details, see commit 04869bd2a39a ("aerc: fix popover menu regression"). The workaround that was added, along with commit b3dc63d69c14 ("complete: only display popover for more than one choice"), forces the completion when there is a single choice. Completely ignoring [ui].completion-min-chars = manual. Only explicitly trigger the completion if the completion key was seen in the keystroke sequence or if completion-min-chars is not set to manual. Use the correct completion key and not hard code Tab. Fixes: 0b0095eeadaf ("complete: allow disabling automatic completion") Fixes: https://todo.sr.ht/~rjarry/aerc/210 References: https://todo.sr.ht/~rjarry/aerc/104 Cc: Skejg <grolleman@zoho.com> Reported-by: Karel Balej <balejk@matfyz.cz> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Karel Balej <balejk@matfyz.cz> Tested-by: Koni Marti <koni.marti@gmail.com>
-rw-r--r--app/aerc.go17
-rw-r--r--doc/aerc-binds.5.scd8
2 files changed, 21 insertions, 4 deletions
diff --git a/app/aerc.go b/app/aerc.go
index 31d3a44b..ee383f86 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -274,20 +274,29 @@ func (aerc *Aerc) getBindings() *config.KeyBindings {
func (aerc *Aerc) simulate(strokes []config.KeyStroke) {
aerc.pendingKeys = []config.KeyStroke{}
+ bindings := aerc.getBindings()
+ complete := aerc.SelectedAccountUiConfig().CompletionMinChars != config.MANUAL_COMPLETE
aerc.simulating += 1
+
for _, stroke := range strokes {
simulated := tcell.NewEventKey(
- stroke.Key, stroke.Rune, tcell.ModNone)
+ stroke.Key, stroke.Rune, stroke.Modifiers)
aerc.Event(simulated)
+ complete = stroke == bindings.CompleteKey
}
aerc.simulating -= 1
- // If we are still focused on the exline, turn on tab complete
if exline, ok := aerc.focused.(*ExLine); ok {
+ // we are still focused on the exline, turn on tab complete
exline.TabComplete(func(cmd string) ([]string, string) {
return aerc.complete(cmd)
})
- // send tab to text input to trigger completion
- exline.Event(tcell.NewEventKey(tcell.KeyTab, 0, tcell.ModNone))
+ if complete {
+ // force completion now
+ exline.Event(tcell.NewEventKey(
+ bindings.CompleteKey.Key,
+ bindings.CompleteKey.Rune,
+ bindings.CompleteKey.Modifiers))
+ }
}
}
diff --git a/doc/aerc-binds.5.scd b/doc/aerc-binds.5.scd
index b00c12d8..6bb2100e 100644
--- a/doc/aerc-binds.5.scd
+++ b/doc/aerc-binds.5.scd
@@ -129,6 +129,14 @@ available in each binding context:
Default: _<tab>_
+ Note: automatic command completion is disabled when simulating
+ keystrokes and re-enabled at the end. When *[ui].completion-min-chars*
+ is set to _manual_ (see *aerc-config*(5)), it is possible to end
+ a keybinding with the completion key to explicitly display the
+ completion menu. E.g.:
+
+ *o* = _:cf<space><tab>_
+
# SUPPORTED KEYS
In addition to letters and some characters (e.g. *a*, *RR*, *gu*, *?*, *!*,