@@ -124,11 +124,15 @@ struct Section {
124
124
125
125
struct CollectContext {
126
126
top_level : bool ,
127
+ include_assignments_in_blocks : bool ,
127
128
}
128
129
129
130
impl CollectContext {
130
131
fn new ( ) -> Self {
131
- Self { top_level : true }
132
+ Self {
133
+ top_level : true ,
134
+ include_assignments_in_blocks : false ,
135
+ }
132
136
}
133
137
}
134
138
@@ -145,14 +149,11 @@ pub(crate) fn document_symbols(
145
149
let root_node = ast. root_node ( ) ;
146
150
let mut result = Vec :: new ( ) ;
147
151
152
+ let mut ctx = CollectContext :: new ( ) ;
153
+ ctx. include_assignments_in_blocks = state. config . symbols . include_assignments_in_blocks ;
154
+
148
155
// Extract and process all symbols from the AST
149
- if let Err ( err) = collect_symbols (
150
- & mut CollectContext :: new ( ) ,
151
- & root_node,
152
- contents,
153
- 0 ,
154
- & mut result,
155
- ) {
156
+ if let Err ( err) = collect_symbols ( & mut ctx, & root_node, contents, 0 , & mut result) {
156
157
log:: error!( "Failed to collect symbols: {err:?}" ) ;
157
158
return Ok ( Vec :: new ( ) ) ;
158
159
}
@@ -443,7 +444,7 @@ fn collect_assignment(
443
444
return collect_assignment_with_function ( ctx, node, contents, symbols) ;
444
445
}
445
446
446
- if ctx. top_level {
447
+ if ctx. top_level || ctx . include_assignments_in_blocks {
447
448
// Collect as generic object, but only if we're at top-level. Assigned
448
449
// objects in nested functions and blocks cause the outline to become
449
450
// too busy.
0 commit comments