@@ -4662,6 +4662,206 @@ const foo = 'bad'
46624662 Ok ( ( ) )
46634663}
46644664
4665+ // #region CONFIGURATION PATH RESOLUTION
4666+
4667+ /// Verifies that a relative `configurationPath` in the extension settings is
4668+ /// resolved against the workspace root URI.
4669+ ///
4670+ /// Regression test for <https://github.com/biomejs/biome/issues/9217>
4671+ #[ tokio:: test]
4672+ async fn relative_configuration_path_resolves_against_root_uri ( ) -> Result < ( ) > {
4673+ let fs = MemoryFileSystem :: default ( ) ;
4674+
4675+ // Place the config in a sub-directory so the path must be relative.
4676+ let config = r#"{
4677+ "formatter": {
4678+ "enabled": false
4679+ }
4680+ }"# ;
4681+ fs. insert ( to_utf8_file_path_buf ( uri ! ( "configs/biome.json" ) ) , config) ;
4682+
4683+ let factory = ServerFactory :: new_with_fs ( Arc :: new ( fs) ) ;
4684+ let ( service, client) = factory. create ( ) . into_inner ( ) ;
4685+ let ( stream, sink) = client. split ( ) ;
4686+ let mut server = Server :: new ( service) ;
4687+
4688+ let ( sender, _) = channel ( CHANNEL_BUFFER_SIZE ) ;
4689+ let reader = tokio:: spawn ( client_handler ( stream, sink, sender) ) ;
4690+
4691+ server. initialize ( ) . await ?;
4692+ server. initialized ( ) . await ?;
4693+
4694+ // Set configurationPath to a relative path (the bug: this used to be
4695+ // resolved against the daemon's cwd instead of the workspace root).
4696+ server
4697+ . load_configuration_with_settings ( WorkspaceSettings {
4698+ configuration_path : Some ( "configs/biome.json" . to_string ( ) ) ,
4699+ ..Default :: default ( )
4700+ } )
4701+ . await ?;
4702+
4703+ server. open_document ( r#"statement( );"# ) . await ?;
4704+
4705+ // The config disables the formatter, so formatting should return no edits.
4706+ let res: Option < Vec < TextEdit > > = server
4707+ . request (
4708+ "textDocument/formatting" ,
4709+ "formatting" ,
4710+ DocumentFormattingParams {
4711+ text_document : TextDocumentIdentifier {
4712+ uri : uri ! ( "document.js" ) ,
4713+ } ,
4714+ options : FormattingOptions {
4715+ tab_size : 4 ,
4716+ insert_spaces : false ,
4717+ properties : HashMap :: default ( ) ,
4718+ trim_trailing_whitespace : None ,
4719+ insert_final_newline : None ,
4720+ trim_final_newlines : None ,
4721+ } ,
4722+ work_done_progress_params : WorkDoneProgressParams {
4723+ work_done_token : None ,
4724+ } ,
4725+ } ,
4726+ )
4727+ . await ?
4728+ . context ( "formatting returned None" ) ?;
4729+
4730+ assert ! (
4731+ res. is_none( ) ,
4732+ "Expected no formatting edits because the config at configs/biome.json disables the formatter. \
4733+ If this fails, the relative configurationPath was not resolved against the workspace root."
4734+ ) ;
4735+
4736+ server. close_document ( ) . await ?;
4737+ server. shutdown ( ) . await ?;
4738+ reader. abort ( ) ;
4739+
4740+ Ok ( ( ) )
4741+ }
4742+
4743+ /// Verifies that a relative `configurationPath` is resolved against the
4744+ /// workspace folder that **contains the file being opened**, not always the
4745+ /// first workspace folder.
4746+ ///
4747+ /// Regression test for <https://github.com/biomejs/biome/issues/9217>
4748+ #[ tokio:: test]
4749+ #[ expect( deprecated) ]
4750+ async fn relative_configuration_path_resolves_against_correct_workspace_folder ( ) -> Result < ( ) > {
4751+ let fs = MemoryFileSystem :: default ( ) ;
4752+
4753+ // test_one has formatting enabled (default), test_two disables it.
4754+ // Both configs live at `<folder>/configs/biome.json`.
4755+ let config_one = r#"{}"# ;
4756+ let config_two = r#"{
4757+ "formatter": {
4758+ "enabled": false
4759+ }
4760+ }"# ;
4761+
4762+ fs. insert (
4763+ to_utf8_file_path_buf ( uri ! ( "test_one/configs/biome.json" ) ) ,
4764+ config_one,
4765+ ) ;
4766+ fs. insert (
4767+ to_utf8_file_path_buf ( uri ! ( "test_two/configs/biome.json" ) ) ,
4768+ config_two,
4769+ ) ;
4770+
4771+ let factory = ServerFactory :: new_with_fs ( Arc :: new ( fs) ) ;
4772+ let ( service, client) = factory. create ( ) . into_inner ( ) ;
4773+ let ( stream, sink) = client. split ( ) ;
4774+ let mut server = Server :: new ( service) ;
4775+
4776+ let ( sender, _) = channel ( CHANNEL_BUFFER_SIZE ) ;
4777+ let reader = tokio:: spawn ( client_handler ( stream, sink, sender) ) ;
4778+
4779+ // Initialize with two workspace folders (test_one, test_two).
4780+ let _res: InitializeResult = server
4781+ . request (
4782+ "initialize" ,
4783+ "_init" ,
4784+ InitializeParams {
4785+ process_id : None ,
4786+ root_path : None ,
4787+ root_uri : Some ( uri ! ( "/" ) ) ,
4788+ initialization_options : None ,
4789+ capabilities : ClientCapabilities :: default ( ) ,
4790+ trace : None ,
4791+ workspace_folders : Some ( vec ! [
4792+ WorkspaceFolder {
4793+ name: "test_one" . to_string( ) ,
4794+ uri: uri!( "test_one" ) ,
4795+ } ,
4796+ WorkspaceFolder {
4797+ name: "test_two" . to_string( ) ,
4798+ uri: uri!( "test_two" ) ,
4799+ } ,
4800+ ] ) ,
4801+ client_info : None ,
4802+ locale : None ,
4803+ work_done_progress_params : Default :: default ( ) ,
4804+ } ,
4805+ )
4806+ . await ?
4807+ . context ( "initialize returned None" ) ?;
4808+
4809+ server. initialized ( ) . await ?;
4810+
4811+ // Set a relative configurationPath. Each workspace folder has its own
4812+ // `configs/biome.json`; the correct one must be picked per file.
4813+ server
4814+ . load_configuration_with_settings ( WorkspaceSettings {
4815+ configuration_path : Some ( "configs/biome.json" . to_string ( ) ) ,
4816+ ..Default :: default ( )
4817+ } )
4818+ . await ?;
4819+
4820+ // Open a file in test_two — its config disables the formatter.
4821+ server
4822+ . open_named_document (
4823+ r#"statement( );"# ,
4824+ uri ! ( "test_two/document.js" ) ,
4825+ "javascript" ,
4826+ )
4827+ . await ?;
4828+
4829+ let res: Option < Vec < TextEdit > > = server
4830+ . request (
4831+ "textDocument/formatting" ,
4832+ "formatting" ,
4833+ DocumentFormattingParams {
4834+ text_document : TextDocumentIdentifier {
4835+ uri : uri ! ( "test_two/document.js" ) ,
4836+ } ,
4837+ options : FormattingOptions {
4838+ tab_size : 4 ,
4839+ insert_spaces : false ,
4840+ properties : HashMap :: default ( ) ,
4841+ trim_trailing_whitespace : None ,
4842+ insert_final_newline : None ,
4843+ trim_final_newlines : None ,
4844+ } ,
4845+ work_done_progress_params : WorkDoneProgressParams {
4846+ work_done_token : None ,
4847+ } ,
4848+ } ,
4849+ )
4850+ . await ?
4851+ . context ( "formatting returned None" ) ?;
4852+
4853+ assert ! (
4854+ res. is_none( ) ,
4855+ "Expected no formatting edits because test_two/configs/biome.json disables the formatter. \
4856+ If this fails, the relative configurationPath was resolved against the wrong workspace folder."
4857+ ) ;
4858+
4859+ server. shutdown ( ) . await ?;
4860+ reader. abort ( ) ;
4861+
4862+ Ok ( ( ) )
4863+ }
4864+
46654865// #endregion
46664866
46674867// #region TEST UTILS
0 commit comments