File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
lib/Terminal/Widgets/Viewer Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -26,16 +26,19 @@ my class DisplayLeaf does DisplayNode {
2626my class DisplayParent does DisplayNode {
2727 has DisplayNode: D @ . children ;
2828 has Bool : D $ . expanded = False ;
29- has & . sort-by is required ;
29+ has & . sort-by ;
3030
3131 # | Refresh children from volatile data and recreate DisplayNodes as needed
3232 method refresh-children () {
33- my $ depth = $ ! depth + 1 ;
34- @ ! children = $ . data . children( : refresh) . sort ( & ! sort-by ) . map : {
33+ my $ depth = $ ! depth + 1 ;
34+ my & create := {
3535 $ _ ~~ VTree::Parent
3636 ?? DisplayParent. new (parent => self , data => $ _ , : $ depth , : & ! sort-by )
3737 !! DisplayLeaf. new ( parent => self , data => $ _ , : $ depth )
38- }
38+ };
39+ @ ! children = & ! sort-by
40+ ?? $ . data . children(: refresh). sort (& ! sort-by ). map (& create )
41+ !! $ . data . children(: refresh). map (& create )
3942 }
4043
4144 # | Toggle expanded state (using set-expanded)
@@ -65,7 +68,7 @@ class Terminal::Widgets::Viewer::Tree
6568 has VTree::Node $ . root ;
6669 has DisplayParent $ . display-root is built(False );
6770 has DisplayNode $ . current-node is built(False );
68- has & . sort-by = *. short-name ;
71+ has & . sort-by ;
6972 has & . process-click ;
7073
7174 has @ ! flat-node-cache ;
You can’t perform that action at this time.
0 commit comments