diff options
Diffstat (limited to 'support/texlab/src/features/symbol/types.rs')
-rw-r--r-- | support/texlab/src/features/symbol/types.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/support/texlab/src/features/symbol/types.rs b/support/texlab/src/features/symbol/types.rs index be0ffeceda..fb3bca217b 100644 --- a/support/texlab/src/features/symbol/types.rs +++ b/support/texlab/src/features/symbol/types.rs @@ -2,8 +2,8 @@ use lsp_types::{DocumentSymbol, Location, Range, SymbolInformation, SymbolKind, use crate::{ db::Word, - util::{lang_data::BibtexEntryTypeCategory, lsp_enums::Structure}, - Db, + util::{self, lang_data::BibtexEntryTypeCategory, lsp_enums::Structure}, + Db, SymbolOptions, }; #[derive(Debug, PartialEq, Eq, Clone, Copy)] @@ -80,6 +80,26 @@ impl InternalSymbol { buffer.push(self); } + pub fn filter(container: &mut Vec<InternalSymbol>, options: &SymbolOptions) { + let mut i = 0; + while i < container.len() { + let symbol = &mut container[i]; + + if util::regex_filter::filter( + &symbol.name, + &options.allowed_patterns, + &options.ignored_patterns, + ) { + Self::filter(&mut symbol.children, options); + i += 1; + } else { + drop(symbol); + let mut symbol = container.remove(i); + container.append(&mut symbol.children); + } + } + } + pub fn into_document_symbol(self, db: &dyn Db) -> DocumentSymbol { let children = self .children |