@@ -52,13 +52,13 @@ const selectionHandler = async (
52
52
return ;
53
53
}
54
54
if ( expand ) {
55
- await Promise . all (
56
- R . dropLast ( 1 , item . path as PathItem [ ] )
57
- . filter ( ( pathItem ) => pathItem . collapsed )
58
- . map ( ( { uuid } ) => logseq . Editor . setBlockCollapsed ( uuid , false ) )
59
- ) ;
55
+ const collapsedItems = ( item . path as PathItem [ ] )
56
+ . filter ( ( pathItem ) => pathItem . collapsed ) ;
57
+ for ( const item of collapsedItems ) {
58
+ await logseq . Editor . setBlockCollapsed ( item . uuid , false ) ;
59
+ }
60
60
}
61
- if ( item ) scrollTo ( item . id as string ) ;
61
+ scrollTo ( item . id as string ) ;
62
62
} ;
63
63
64
64
@@ -67,7 +67,8 @@ const makeCommands = (
67
67
mode : ModeOption ,
68
68
maxDepth = Infinity
69
69
) => {
70
- const items : Command [ ] = [ ] ;
70
+ const entries : Command [ ] = [ ] ;
71
+
71
72
const recurse = (
72
73
block : BlockEntity ,
73
74
depth : number ,
@@ -109,25 +110,28 @@ const makeCommands = (
109
110
color : 'transparent' ,
110
111
path : path ,
111
112
} ;
112
- items . push ( cmd ) ;
113
+ entries . push ( cmd ) ;
114
+
113
115
const children = block . children || [ ] ;
114
116
if ( children . length ) {
117
+ const parentPathItem : PathItem = {
118
+ uuid : block . uuid ,
119
+ collapsed : block [ 'collapsed?' ] ,
120
+ } ;
115
121
( children as BlockEntity [ ] ) . forEach (
116
- ( block ) => recurse (
117
- block ,
122
+ ( child ) => recurse (
123
+ child ,
118
124
depth + 1 ,
119
- [ ...path , {
120
- uuid : block . uuid ,
121
- collapsed : block [ 'collapsed?' ] ,
122
- } ]
125
+ [ ...path , parentPathItem ]
123
126
)
124
127
) ;
125
128
}
126
129
} ;
130
+
127
131
blocks . forEach (
128
132
( block ) => recurse ( block , 0 , [ ] )
129
133
) ;
130
- return items ;
134
+ return entries ;
131
135
} ;
132
136
133
137
0 commit comments