aboutsummaryrefslogtreecommitdiffstats
path: root/app/aerc.go
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 /app/aerc.go
parent1aa1f46a2cb8cdc62eeaf520870fc3de3d3eed25 (diff)
downloadaerc-64d76e32d1d4db0f9512a71c2896253f23eb3c06.tar.gz
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>
Diffstat (limited to 'app/aerc.go')
-rw-r--r--app/aerc.go17
1 files changed, 13 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))
+ }
}
}