From 115447e57f015b1805d2d58d1ae46beaff2299e5 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 7 Jun 2022 10:59:05 -0500 Subject: dirlist: fix panic when disconnecting with dirlist-tree=false Commit 2027223a created a panic when attempting to clear the dirlist when the config option dirlist-tree is set to false. This patch fixes that panic by creating a dirlist.ClearList() function to prevent needing to check a callback. Tested with both dirlist-tree=false and true Fixes: 2027223ab302 ("fix: clear dirlist on disconnect") Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- widgets/dirtree.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'widgets/dirtree.go') diff --git a/widgets/dirtree.go b/widgets/dirtree.go index 24094e57..1130329a 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -32,6 +32,10 @@ func NewDirectoryTree(dirlist *DirectoryList, pathSeparator string) DirectoryLis return dt } +func (dt *DirectoryTree) ClearList() { + dt.list = make([]*types.Thread, 0) +} + func (dt *DirectoryTree) UpdateList(done func([]string)) { dt.DirectoryList.UpdateList(func(dirs []string) { if done != nil { -- cgit