mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-19 18:55:01 +00:00
fix: symbols doesn't show if pattern is not provided (#569)
This commit is contained in:
parent
666e95c540
commit
c6da5590ca
1 changed files with 18 additions and 18 deletions
|
@ -43,19 +43,16 @@ impl SemanticRequest for SymbolRequest {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let uri = path_to_url(&path).unwrap();
|
let uri = path_to_url(&path).unwrap();
|
||||||
let res = get_lexical_hierarchy(source.clone(), LexicalScopeKind::Symbol).and_then(
|
let res =
|
||||||
|symbols| {
|
get_lexical_hierarchy(source.clone(), LexicalScopeKind::Symbol).map(|symbols| {
|
||||||
self.pattern.as_ref().map(|pattern| {
|
filter_document_symbols(
|
||||||
filter_document_symbols(
|
&symbols,
|
||||||
&symbols,
|
self.pattern.as_deref(),
|
||||||
pattern,
|
&source,
|
||||||
&source,
|
&uri,
|
||||||
&uri,
|
ctx.position_encoding(),
|
||||||
ctx.position_encoding(),
|
)
|
||||||
)
|
});
|
||||||
})
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(mut res) = res {
|
if let Some(mut res) = res {
|
||||||
symbols.append(&mut res)
|
symbols.append(&mut res)
|
||||||
|
@ -69,7 +66,7 @@ impl SemanticRequest for SymbolRequest {
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
fn filter_document_symbols(
|
fn filter_document_symbols(
|
||||||
symbols: &[LexicalHierarchy],
|
symbols: &[LexicalHierarchy],
|
||||||
query_string: &str,
|
query_string: Option<&str>,
|
||||||
source: &Source,
|
source: &Source,
|
||||||
uri: &Url,
|
uri: &Url,
|
||||||
position_encoding: PositionEncoding,
|
position_encoding: PositionEncoding,
|
||||||
|
@ -80,11 +77,14 @@ fn filter_document_symbols(
|
||||||
[e].into_iter()
|
[e].into_iter()
|
||||||
.chain(e.children.as_deref().into_iter().flatten())
|
.chain(e.children.as_deref().into_iter().flatten())
|
||||||
})
|
})
|
||||||
.filter(|e| e.info.name.contains(query_string))
|
.flat_map(|e| {
|
||||||
.map(|e| {
|
if query_string.is_some_and(|s| !e.info.name.contains(s)) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let rng = typst_to_lsp::range(e.info.range.clone(), source, position_encoding);
|
let rng = typst_to_lsp::range(e.info.range.clone(), source, position_encoding);
|
||||||
|
|
||||||
SymbolInformation {
|
Some(SymbolInformation {
|
||||||
name: e.info.name.clone(),
|
name: e.info.name.clone(),
|
||||||
kind: e.info.kind.clone().try_into().unwrap(),
|
kind: e.info.kind.clone().try_into().unwrap(),
|
||||||
tags: None,
|
tags: None,
|
||||||
|
@ -94,7 +94,7 @@ fn filter_document_symbols(
|
||||||
range: rng,
|
range: rng,
|
||||||
},
|
},
|
||||||
container_name: None,
|
container_name: None,
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue