Skip to content

Commit a4f5a00

Browse files
committed
Make inclusion in outline of assignments in blocks optional
1 parent 2ce4f01 commit a4f5a00

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

crates/ark/src/lsp/symbols.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,15 @@ struct Section {
124124

125125
struct CollectContext {
126126
top_level: bool,
127+
include_assignments_in_blocks: bool,
127128
}
128129

129130
impl CollectContext {
130131
fn new() -> Self {
131-
Self { top_level: true }
132+
Self {
133+
top_level: true,
134+
include_assignments_in_blocks: false,
135+
}
132136
}
133137
}
134138

@@ -145,14 +149,11 @@ pub(crate) fn document_symbols(
145149
let root_node = ast.root_node();
146150
let mut result = Vec::new();
147151

152+
let mut ctx = CollectContext::new();
153+
ctx.include_assignments_in_blocks = state.config.symbols.include_assignments_in_blocks;
154+
148155
// 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) {
156157
log::error!("Failed to collect symbols: {err:?}");
157158
return Ok(Vec::new());
158159
}
@@ -443,7 +444,7 @@ fn collect_assignment(
443444
return collect_assignment_with_function(ctx, node, contents, symbols);
444445
}
445446

446-
if ctx.top_level {
447+
if ctx.top_level || ctx.include_assignments_in_blocks {
447448
// Collect as generic object, but only if we're at top-level. Assigned
448449
// objects in nested functions and blocks cause the outline to become
449450
// too busy.

0 commit comments

Comments
 (0)