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;
|
||||
};
|
||||
let uri = path_to_url(&path).unwrap();
|
||||
let res = get_lexical_hierarchy(source.clone(), LexicalScopeKind::Symbol).and_then(
|
||||
|symbols| {
|
||||
self.pattern.as_ref().map(|pattern| {
|
||||
let res =
|
||||
get_lexical_hierarchy(source.clone(), LexicalScopeKind::Symbol).map(|symbols| {
|
||||
filter_document_symbols(
|
||||
&symbols,
|
||||
pattern,
|
||||
self.pattern.as_deref(),
|
||||
&source,
|
||||
&uri,
|
||||
ctx.position_encoding(),
|
||||
)
|
||||
})
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if let Some(mut res) = res {
|
||||
symbols.append(&mut res)
|
||||
|
@ -69,7 +66,7 @@ impl SemanticRequest for SymbolRequest {
|
|||
#[allow(deprecated)]
|
||||
fn filter_document_symbols(
|
||||
symbols: &[LexicalHierarchy],
|
||||
query_string: &str,
|
||||
query_string: Option<&str>,
|
||||
source: &Source,
|
||||
uri: &Url,
|
||||
position_encoding: PositionEncoding,
|
||||
|
@ -80,11 +77,14 @@ fn filter_document_symbols(
|
|||
[e].into_iter()
|
||||
.chain(e.children.as_deref().into_iter().flatten())
|
||||
})
|
||||
.filter(|e| e.info.name.contains(query_string))
|
||||
.map(|e| {
|
||||
.flat_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);
|
||||
|
||||
SymbolInformation {
|
||||
Some(SymbolInformation {
|
||||
name: e.info.name.clone(),
|
||||
kind: e.info.kind.clone().try_into().unwrap(),
|
||||
tags: None,
|
||||
|
@ -94,7 +94,7 @@ fn filter_document_symbols(
|
|||
range: rng,
|
||||
},
|
||||
container_name: None,
|
||||
}
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue