diff options
author | Robin Jarry <robin@jarry.cc> | 2022-11-01 12:37:16 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-11-06 23:16:08 +0100 |
commit | 6b0b5596dee5dda9fb367cbf8c82e52b9e6125a3 (patch) | |
tree | 9aeabf8ce24009bbdf28829647827951f21e425e /widgets | |
parent | 14ceca320065656ea31994191f9e74d254a72e04 (diff) | |
download | aerc-6b0b5596dee5dda9fb367cbf8c82e52b9e6125a3.tar.gz |
auto-completion: add option to require a min number of chars
When doing address completion via commands that take a while to run,
having the completion trigger even with a single character can be
non-optimal. Add an option to allow requiring a minimum number of
characters to actually run the completion command.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/compose.go | 18 | ||||
-rw-r--r-- | widgets/exline.go | 18 |
2 files changed, 30 insertions, 6 deletions
diff --git a/widgets/compose.go b/widgets/compose.go index 6e34365a..14a75bb6 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -214,7 +214,11 @@ func (c *Composer) buildComposeHeader(aerc *Aerc, cmpl *completer.Completer) { c.layout[i][j] = h // normalize to lowercase e := newHeaderEditor(h, c.header, uiConfig) if aerc.conf.Ui.CompletionPopovers { - e.input.TabComplete(cmpl.ForHeader(h), uiConfig.CompletionDelay) + e.input.TabComplete( + cmpl.ForHeader(h), + uiConfig.CompletionDelay, + uiConfig.CompletionMinChars, + ) } c.editors[h] = e switch h { @@ -233,7 +237,11 @@ func (c *Composer) buildComposeHeader(aerc *Aerc, cmpl *completer.Completer) { if _, ok := c.editors[h]; !ok { e := newHeaderEditor(h, c.header, uiConfig) if aerc.conf.Ui.CompletionPopovers { - e.input.TabComplete(cmpl.ForHeader(h), uiConfig.CompletionDelay) + e.input.TabComplete( + cmpl.ForHeader(h), + uiConfig.CompletionDelay, + uiConfig.CompletionMinChars, + ) } c.editors[h] = e c.focusable = append(c.focusable, e) @@ -1005,7 +1013,11 @@ func (c *Composer) AddEditor(header string, value string, appendHeader bool) { uiConfig := c.acct.UiConfig() e := newHeaderEditor(header, c.header, uiConfig) if uiConfig.CompletionPopovers { - e.input.TabComplete(c.completer.ForHeader(header), uiConfig.CompletionDelay) + e.input.TabComplete( + c.completer.ForHeader(header), + uiConfig.CompletionDelay, + uiConfig.CompletionMinChars, + ) } c.editors[header] = e c.layout = append(c.layout, []string{header}) diff --git a/widgets/exline.go b/widgets/exline.go index 789ccde8..5cf4338d 100644 --- a/widgets/exline.go +++ b/widgets/exline.go @@ -23,7 +23,11 @@ func NewExLine(conf *config.AercConfig, cmd string, commit func(cmd string), fin ) *ExLine { input := ui.NewTextInput("", &conf.Ui).Prompt(":").Set(cmd) if conf.Ui.CompletionPopovers { - input.TabComplete(tabcomplete, conf.Ui.CompletionDelay) + input.TabComplete( + tabcomplete, + conf.Ui.CompletionDelay, + conf.Ui.CompletionMinChars, + ) } exline := &ExLine{ commit: commit, @@ -37,7 +41,11 @@ func NewExLine(conf *config.AercConfig, cmd string, commit func(cmd string), fin } func (x *ExLine) TabComplete(tabComplete func(string) ([]string, string)) { - x.input.TabComplete(tabComplete, x.conf.Ui.CompletionDelay) + x.input.TabComplete( + tabComplete, + x.conf.Ui.CompletionDelay, + x.conf.Ui.CompletionMinChars, + ) } func NewPrompt(conf *config.AercConfig, prompt string, commit func(text string), @@ -45,7 +53,11 @@ func NewPrompt(conf *config.AercConfig, prompt string, commit func(text string), ) *ExLine { input := ui.NewTextInput("", &conf.Ui).Prompt(prompt) if conf.Ui.CompletionPopovers { - input.TabComplete(tabcomplete, conf.Ui.CompletionDelay) + input.TabComplete( + tabcomplete, + conf.Ui.CompletionDelay, + conf.Ui.CompletionMinChars, + ) } exline := &ExLine{ commit: commit, |