diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-11-18 02:07:06 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-11-23 00:14:54 +0100 |
commit | 85d0936df6861c41a1dddd91a2f3b97afd8e127a (patch) | |
tree | 72def6d94ba56f508bdc6cbf051865c000d968dc /app/dirtree.go | |
parent | 48b9589d8bbe4ec8982c08a9fe6e59b77734eb80 (diff) | |
download | aerc-85d0936df6861c41a1dddd91a2f3b97afd8e127a.tar.gz |
dirlist/dirtree: context handling
Add a NewContext() function that extracts and handles the canceling and
re-creation of a new context for the directory list. This enables a
better control of the context cancellation especially for a directory
tree when a virtual node is selected. Before, the previous folder would
have been opened if a virtual node was selected.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app/dirtree.go')
-rw-r--r-- | app/dirtree.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/dirtree.go b/app/dirtree.go index 6a3b34c0..8f8730b4 100644 --- a/app/dirtree.go +++ b/app/dirtree.go @@ -256,12 +256,17 @@ func (dt *DirectoryTree) NextPrev(delta int) { } } - dt.listIdx = newIdx + dt.selectIndex(newIdx) +} + +func (dt *DirectoryTree) selectIndex(i int) { + dt.listIdx = i if path := dt.getDirectory(dt.list[dt.listIdx]); path != "" { dt.virtual = false dt.Select(path) } else { dt.virtual = true + dt.NewContext() dt.virtualCb() } } @@ -274,10 +279,7 @@ func (dt *DirectoryTree) CollapseFolder() { // highlight parent node and select it for i, t := range dt.list { if t == node.Parent { - dt.listIdx = i - if path := dt.getDirectory(dt.list[dt.listIdx]); path != "" { - dt.Select(path) - } + dt.selectIndex(i) } } } else { |