11import  *  as  vscode  from  "vscode" ; 
2- import  type   *  as  lc  from  "vscode-languageclient/node" ; 
2+ import  *  as  lc  from  "vscode-languageclient/node" ; 
33import  *  as  ra  from  "./lsp_ext" ; 
44
55import  {  Config ,  prepareVSCodeConfig  }  from  "./config" ; 
@@ -22,6 +22,7 @@ import {
2222import  {  execRevealDependency  }  from  "./commands" ; 
2323import  {  PersistentState  }  from  "./persistent_state" ; 
2424import  {  bootstrap  }  from  "./bootstrap" ; 
25+ import  {  RustAnalyzerExtensionApi  }  from  "./main" ; 
2526
2627// We only support local folders, not eg. Live Share (`vlsl:` scheme), so don't activate if 
2728// only those are in use. We use "Empty" to represent these scenarios 
@@ -64,7 +65,7 @@ export type CtxInit = Ctx & {
6465    readonly  client : lc . LanguageClient ; 
6566} ; 
6667
67- export  class  Ctx  { 
68+ export  class  Ctx  implements   RustAnalyzerExtensionApi   { 
6869    readonly  statusBar : vscode . StatusBarItem ; 
6970    config : Config ; 
7071    readonly  workspace : Workspace ; 
@@ -190,7 +191,7 @@ export class Ctx {
190191                const  command  =  `${ this . config . discoverProjectRunner }  ; 
191192                log . info ( `running command: ${ command }  ) ; 
192193                const  project : JsonProject  =  await  vscode . commands . executeCommand ( command ) ; 
193-                 this . addToDiscoveredWorkspaces ( [ project ] ) ; 
194+                 this . setWorkspaces ( [ project ] ) ; 
194195            } 
195196
196197            if  ( this . workspace . kind  ===  "Detached Files" )  { 
@@ -342,15 +343,17 @@ export class Ctx {
342343        return  this . _serverPath ; 
343344    } 
344345
345-     addToDiscoveredWorkspaces ( workspaces : JsonProject [ ] )  { 
346-         for  ( const  workspace  of  workspaces )  { 
347-             const  index  =  this . config . discoveredWorkspaces . indexOf ( workspace ) ; 
348-             if  ( ~ index )  { 
349-                 this . config . discoveredWorkspaces [ index ]  =  workspace ; 
350-             }  else  { 
351-                 this . config . discoveredWorkspaces . push ( workspace ) ; 
352-             } 
353-         } 
346+     setWorkspaces ( workspaces : JsonProject [ ] )  { 
347+         this . config . discoveredWorkspaces  =  workspaces ; 
348+     } 
349+ 
350+     async  notifyRustAnalyzer ( ) : Promise < void >  { 
351+         // this is a workaround to avoid needing writing the `rust-project.json` into 
352+         // a workspace-level VS Code-specific settings folder. We'd like to keep the 
353+         // `rust-project.json` entirely in-memory. 
354+         await  this . client ?. sendNotification ( lc . DidChangeConfigurationNotification . type ,  { 
355+             settings : "" , 
356+         } ) ; 
354357    } 
355358
356359    private  updateCommands ( forceDisable ?: "disable" )  { 
0 commit comments