dirlist: use shorter delay before listing directory contents

1 second is a bit excessive. Use 200ms which should cover most quick
folder changes.

Add an option to make that delay configurable by the users.

References: https://todo.sr.ht/~rjarry/aerc/16
Fixes: cb3090956c ("dirlist: skip unnecessary change-folder action")
Suggested-by: Koni Marti <koni.marti@gmail.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Robin Jarry 2022-01-28 10:17:13 +01:00
parent cdec23323c
commit a5c046efe3
4 changed files with 18 additions and 1 deletions

View File

@ -74,6 +74,13 @@ pinned-tab-marker='`'
# Default: %n %>r # Default: %n %>r
dirlist-format=%n %>r dirlist-format=%n %>r
# Delay after which the messages are actually listed when entering a directory.
# This avoids loading messages when skipping over folders and makes the UI more
# responsive. If you do not want that, set it to 0s.
#
# Default: 200ms
dirlist-delay=200ms
# List of space-separated criteria to sort the messages by, see *sort* # List of space-separated criteria to sort the messages by, see *sort*
# command in *aerc*(1) for reference. Prefixing a criterion with "-r " # command in *aerc*(1) for reference. Prefixing a criterion with "-r "
# reverses that criterion. # reverses that criterion.

View File

@ -47,6 +47,7 @@ type UIConfig struct {
Spinner string `ini:"spinner"` Spinner string `ini:"spinner"`
SpinnerDelimiter string `ini:"spinner-delimiter"` SpinnerDelimiter string `ini:"spinner-delimiter"`
DirListFormat string `ini:"dirlist-format"` DirListFormat string `ini:"dirlist-format"`
DirListDelay time.Duration `ini:"dirlist-delay"`
Sort []string `delim:" "` Sort []string `delim:" "`
NextMessageOnDelete bool `ini:"next-message-on-delete"` NextMessageOnDelete bool `ini:"next-message-on-delete"`
CompletionDelay time.Duration `ini:"completion-delay"` CompletionDelay time.Duration `ini:"completion-delay"`
@ -564,6 +565,7 @@ func LoadConfigFromFile(root *string, sharedir string, logger *log.Logger) (*Aer
Spinner: "[..] , [..] , [..] , [..] , [..], [..] , [..] , [..] ", Spinner: "[..] , [..] , [..] , [..] , [..], [..] , [..] , [..] ",
SpinnerDelimiter: ",", SpinnerDelimiter: ",",
DirListFormat: "%n %>r", DirListFormat: "%n %>r",
DirListDelay: 200 * time.Millisecond,
NextMessageOnDelete: true, NextMessageOnDelete: true,
CompletionDelay: 250 * time.Millisecond, CompletionDelay: 250 * time.Millisecond,
CompletionPopovers: true, CompletionPopovers: true,

View File

@ -177,6 +177,14 @@ These options are configured in the *[ui]* section of aerc.conf.
| %>X | %>X
: make format specifier 'X' be right justified : make format specifier 'X' be right justified
*dirlist-delay*
Delay after which the messages are actually listed when entering
a directory. This avoids loading messages when skipping over folders
and makes the UI more responsive. If you do not want that, set it to
0s.
Default: 200ms
*next-message-on-delete* *next-message-on-delete*
Moves to next message when the current message is deleted Moves to next message when the current message is deleted

View File

@ -96,7 +96,7 @@ func (dirlist *DirectoryList) Select(name string) {
go func() { go func() {
select { select {
case <-time.After(1 * time.Second): case <-time.After(dirlist.aercConf.Ui.DirListDelay):
dirlist.worker.PostAction(&types.OpenDirectory{Directory: name}, dirlist.worker.PostAction(&types.OpenDirectory{Directory: name},
func(msg types.WorkerMessage) { func(msg types.WorkerMessage) {
switch msg.(type) { switch msg.(type) {