Skip to content

Commit 50fdaeb

Browse files
authored
Preserve specified filters on refresh.
1 parent 8ecd00e commit 50fdaeb

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

render/navigation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ func (n *Navigation) RefreshEntry() (chan struct{}, chan error, error) {
301301

302302
n.entry.Child = nil
303303

304-
t := structure.NewTree(n.entry, structure.WithPartialRoot())
304+
t := n.tree.Clone(n.entry, structure.WithPartialRoot())
305+
305306
doneChan, errChan := t.TraverseAsync(true)
306307

307308
go func() {

structure/tree.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ func NewTree(root *Entry, opts ...TreeOpt) *Tree {
8686
return t
8787
}
8888

89+
// Clone clones the existing *Tree instance. It creates a new Tree instance and
90+
// copies all the predefined settings, except for the root Entry. The root still
91+
// must be specified explicitly, and the copied settings can be overwritten with
92+
// the optional set of TreeOpt options.
93+
func (t *Tree) Clone(root *Entry, opts ...TreeOpt) *Tree {
94+
clonedTree := &Tree{
95+
root: root,
96+
cache: t.cache,
97+
exclude: t.exclude,
98+
fiFilters: t.fiFilters,
99+
partialRoot: t.partialRoot,
100+
}
101+
102+
for _, opt := range opts {
103+
opt(clonedTree)
104+
}
105+
106+
return clonedTree
107+
}
108+
89109
// Root returns a root *Entry node for the current tree.
90110
func (t *Tree) Root() *Entry {
91111
return t.root

0 commit comments

Comments
 (0)