@@ -583,6 +583,8 @@ mod tests {
583
583
use tower_lsp:: lsp_types:: Position ;
584
584
585
585
use super :: * ;
586
+ use crate :: lsp:: config:: LspConfig ;
587
+ use crate :: lsp:: config:: WorkspaceSymbolsConfig ;
586
588
use crate :: lsp:: documents:: Document ;
587
589
588
590
fn test_symbol ( code : & str ) -> Vec < DocumentSymbol > {
@@ -894,4 +896,41 @@ a <- function() {
894
896
895
897
insta:: assert_debug_snapshot!( symbols) ;
896
898
}
899
+
900
+ #[ test]
901
+ fn test_workspace_symbols_include_comment_sections ( ) {
902
+ fn run ( include_comment_sections : bool ) -> Vec < String > {
903
+ let code = "# Section ----\n foo <- 1" ;
904
+
905
+ let mut config = LspConfig :: default ( ) ;
906
+ config. workspace_symbols = WorkspaceSymbolsConfig {
907
+ include_comment_sections,
908
+ } ;
909
+ let mut state = WorldState :: default ( ) ;
910
+ state. config = config;
911
+
912
+ // Index the document
913
+ let doc = Document :: new ( code, None ) ;
914
+ indexer:: update ( & doc, std:: path:: Path :: new ( "/test.R" ) ) . unwrap ( ) ;
915
+
916
+ // Query for all symbols
917
+ let params = WorkspaceSymbolParams {
918
+ query : "Section" . to_string ( ) ,
919
+ ..Default :: default ( )
920
+ } ;
921
+ let result = super :: symbols ( & params, & state) . unwrap ( ) ;
922
+ let out = result. into_iter ( ) . map ( |s| s. name ) . collect ( ) ;
923
+
924
+ indexer:: indexer_clear ( ) ;
925
+ out
926
+ }
927
+
928
+ // Should include section when true
929
+ let with_sections = run ( true ) ;
930
+ assert ! ( with_sections. contains( & "Section" . to_string( ) ) ) ;
931
+
932
+ // Should not include section when false
933
+ let without_sections = run ( false ) ;
934
+ assert ! ( !without_sections. contains( & "Section" . to_string( ) ) ) ;
935
+ }
897
936
}
0 commit comments