@@ -29,7 +29,7 @@ use lsp_types::{
2929    PartialResultParams ,  Position ,  Range ,  RenameFilesParams ,  TextDocumentItem , 
3030    TextDocumentPositionParams ,  WorkDoneProgressParams , 
3131} ; 
32- use  rust_analyzer:: lsp:: ext:: { OnEnter ,  Runnables ,  RunnablesParams } ; 
32+ use  rust_analyzer:: lsp:: ext:: { OnEnter ,  Runnables ,  RunnablesParams ,   UnindexedProject } ; 
3333use  serde_json:: json; 
3434use  test_utils:: skip_slow_tests; 
3535
@@ -588,6 +588,66 @@ fn main() {{}}
588588    ) ; 
589589} 
590590
591+ #[ test]  
592+ fn  test_opening_a_file_outside_of_indexed_workspace ( )  { 
593+     if  skip_slow_tests ( )  { 
594+         return ; 
595+     } 
596+ 
597+     let  tmp_dir = TestDir :: new ( ) ; 
598+     let  path = tmp_dir. path ( ) ; 
599+ 
600+     let  project = json ! ( { 
601+         "roots" :  [ path] , 
602+         "crates" :  [  { 
603+             "root_module" :  path. join( "src/crate_one/lib.rs" ) , 
604+             "deps" :  [ ] , 
605+             "edition" :  "2015" , 
606+             "cfg" :  [  "cfg_atom_1" ,  "feature=\" cfg_1\" " ] , 
607+         }  ] 
608+     } ) ; 
609+ 
610+     let  code = format ! ( 
611+         r#" 
612+ //- /rust-project.json 
613+ {project} 
614+ 
615+ //- /src/crate_one/lib.rs 
616+ mod bar; 
617+ 
618+ fn main() {{}} 
619+ "# , 
620+     ) ; 
621+ 
622+     let  server = Project :: with_fixture ( & code) 
623+         . tmp_dir ( tmp_dir) 
624+         . with_config ( serde_json:: json!( { 
625+             "notifications" :  { 
626+                 "unindexedProject" :  true 
627+             } , 
628+         } ) ) 
629+         . server ( ) 
630+         . wait_until_workspace_is_loaded ( ) ; 
631+ 
632+     let  uri = server. doc_id ( & format ! ( "src/crate_two/lib.rs" ) ) . uri ; 
633+     server. notification :: < DidOpenTextDocument > ( DidOpenTextDocumentParams  { 
634+         text_document :  TextDocumentItem  { 
635+             uri :  uri. clone ( ) , 
636+             language_id :  "rust" . to_string ( ) , 
637+             version :  0 , 
638+             text :  "/// Docs\n fn foo() {}" . to_string ( ) , 
639+         } , 
640+     } ) ; 
641+     let  expected = json ! ( { 
642+         "textDocuments" :  [ 
643+             { 
644+                 "uri" :  uri
645+             } 
646+         ] 
647+     } ) ; 
648+     server. expect_notification :: < UnindexedProject > ( expected) ; 
649+ } 
650+ 
591651#[ test]  
592652fn  diagnostics_dont_block_typing ( )  { 
593653    if  skip_slow_tests ( )  { 
0 commit comments