@@ -129,13 +129,16 @@ impl WorkspaceWorker {
129129 id : format ! ( "watcher-formatter-{}" , self . root_uri. as_str( ) ) ,
130130 method : "workspace/didChangeWatchedFiles" . to_string ( ) ,
131131 register_options : Some ( json ! ( DidChangeWatchedFilesRegistrationOptions {
132- watchers: vec![ FileSystemWatcher {
133- glob_pattern: GlobPattern :: Relative ( RelativePattern {
134- base_uri: OneOf :: Right ( self . root_uri. clone( ) ) ,
135- pattern: format_patterns
136- } ) ,
137- kind: Some ( WatchKind :: all( ) ) , // created, deleted, changed
138- } ]
132+ watchers: format_patterns
133+ . into_iter( )
134+ . map( |pattern| FileSystemWatcher {
135+ glob_pattern: GlobPattern :: Relative ( RelativePattern {
136+ base_uri: OneOf :: Right ( self . root_uri. clone( ) ) ,
137+ pattern,
138+ } ) ,
139+ kind: Some ( WatchKind :: all( ) ) , // created, deleted, changed
140+ } )
141+ . collect:: <Vec <_>>( ) ,
139142 } ) ) ,
140143 } ) ;
141144 }
@@ -378,7 +381,7 @@ impl WorkspaceWorker {
378381 formatting = true ;
379382
380383 // Extract pattern data without holding the lock
381- let pattern = {
384+ let patterns = {
382385 let formatter_guard = self . server_formatter . read ( ) . await ;
383386 formatter_guard. as_ref ( ) . and_then ( |formatter| {
384387 formatter. get_changed_watch_patterns (
@@ -388,7 +391,7 @@ impl WorkspaceWorker {
388391 } )
389392 } ;
390393
391- if let Some ( pattern ) = pattern {
394+ if let Some ( patterns ) = patterns {
392395 if current_option. format . experimental {
393396 // unregister the old watcher
394397 unregistrations. push ( Unregistration {
@@ -401,13 +404,16 @@ impl WorkspaceWorker {
401404 id : format ! ( "watcher-formatter-{}" , self . root_uri. as_str( ) ) ,
402405 method : "workspace/didChangeWatchedFiles" . to_string ( ) ,
403406 register_options : Some ( json ! ( DidChangeWatchedFilesRegistrationOptions {
404- watchers: vec![ FileSystemWatcher {
405- glob_pattern: GlobPattern :: Relative ( RelativePattern {
406- base_uri: OneOf :: Right ( self . root_uri. clone( ) ) ,
407- pattern
408- } ) ,
409- kind: Some ( WatchKind :: all( ) ) , // created, deleted, changed
410- } ]
407+ watchers: patterns
408+ . into_iter( )
409+ . map( |pattern| FileSystemWatcher {
410+ glob_pattern: GlobPattern :: Relative ( RelativePattern {
411+ base_uri: OneOf :: Right ( self . root_uri. clone( ) ) ,
412+ pattern,
413+ } ) ,
414+ kind: Some ( WatchKind :: all( ) ) , // created, deleted, changed
415+ } )
416+ . collect:: <Vec <_>>( ) ,
411417 } ) ) ,
412418 } ) ;
413419 }
@@ -679,7 +685,11 @@ mod test_watchers {
679685
680686 assert_eq ! ( watchers. len( ) , 2 ) ;
681687 tester. assert_eq_registration ( & watchers[ 0 ] , "linter" , & [ "**/.oxlintrc.json" ] ) ;
682- tester. assert_eq_registration ( & watchers[ 1 ] , "formatter" , & [ ".oxfmtrc.json" ] ) ;
688+ tester. assert_eq_registration (
689+ & watchers[ 1 ] ,
690+ "formatter" ,
691+ & [ ".oxfmtrc.json" , ".oxfmtrc.jsonc" ] ,
692+ ) ;
683693 }
684694
685695 #[ test]
@@ -835,7 +845,11 @@ mod test_watchers {
835845
836846 assert_eq ! ( unregistrations. len( ) , 0 ) ;
837847 assert_eq ! ( registration. len( ) , 1 ) ;
838- tester. assert_eq_registration ( & registration[ 0 ] , "formatter" , & [ ".oxfmtrc.json" ] ) ;
848+ tester. assert_eq_registration (
849+ & registration[ 0 ] ,
850+ "formatter" ,
851+ & [ ".oxfmtrc.json" , ".oxfmtrc.jsonc" ] ,
852+ ) ;
839853 }
840854
841855 #[ test]
0 commit comments