@@ -2,6 +2,15 @@ use emmylua_code_analysis::{DbIndex, LuaCompilation, LuaSemanticDeclId, LuaType}
22use lsp_types:: { OneOf , SymbolKind , SymbolTag , WorkspaceSymbol , WorkspaceSymbolResponse } ;
33use tokio_util:: sync:: CancellationToken ;
44
5+ /// if query contains uppercase, do case-sensitive match; otherwise, ignore case
6+ fn match_symbol ( text : & str , query : & str ) -> bool {
7+ if query. chars ( ) . any ( |c| c. is_uppercase ( ) ) {
8+ text. contains ( query)
9+ } else {
10+ text. to_lowercase ( ) . contains ( & query. to_lowercase ( ) )
11+ }
12+ }
13+
514pub fn build_workspace_symbols (
615 compilation : & LuaCompilation ,
716 query : String ,
@@ -32,7 +41,7 @@ fn add_global_variable_symbols(
3241 return None ;
3342 }
3443
35- if decl. get_name ( ) . contains ( query) {
44+ if match_symbol ( decl. get_name ( ) , query) {
3645 let typ = db
3746 . get_type_index ( )
3847 . get_type_cache ( & decl_id. into ( ) )
@@ -78,7 +87,7 @@ fn add_type_symbols(
7887 return None ;
7988 }
8089
81- if typ. get_full_name ( ) . contains ( query) {
90+ if match_symbol ( typ. get_full_name ( ) , query) {
8291 let property_owner_id = LuaSemanticDeclId :: TypeDecl ( typ. get_id ( ) ) ;
8392 let location = typ. get_locations ( ) . first ( ) ?;
8493 let document = db. get_vfs ( ) . get_document ( & location. file_id ) ?;
0 commit comments