@@ -34,7 +34,7 @@ import {
3434} from "../utils" ;
3535import { StudioActions } from "./studio" ;
3636import { NodeBase , PackageNode , RootNode } from "../explorer/nodes" ;
37- import { updateIndexForDocument } from "../utils/documentIndex" ;
37+ import { getUrisForDocument , updateIndexForDocument } from "../utils/documentIndex" ;
3838
3939async function compileFlags ( ) : Promise < string > {
4040 const defaultFlags = config ( ) . compileFlags ;
@@ -249,12 +249,11 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
249249}
250250
251251export async function compile ( docs : CurrentFile [ ] , flags ?: string ) : Promise < any > {
252- const conf = vscode . workspace . getConfiguration (
253- "objectscript" ,
254- vscode . workspace . getWorkspaceFolder ( docs [ 0 ] . uri ) || docs [ 0 ] . uri
255- ) ;
252+ const wsFolder = vscode . workspace . getWorkspaceFolder ( docs [ 0 ] . uri ) ;
253+ const conf = vscode . workspace . getConfiguration ( "objectscript" , wsFolder || docs [ 0 ] . uri ) ;
256254 flags = flags || conf . get ( "compileFlags" ) ;
257255 const api = new AtelierAPI ( docs [ 0 ] . uri ) ;
256+ const docNames = docs . map ( ( d ) => d . name ) ;
258257 return vscode . window
259258 . withProgress (
260259 {
@@ -264,18 +263,31 @@ export async function compile(docs: CurrentFile[], flags?: string): Promise<any>
264263 } ,
265264 ( progress , token : vscode . CancellationToken ) =>
266265 api
267- . asyncCompile (
268- docs . map ( ( el ) => el . name ) ,
269- token ,
270- flags
271- )
266+ . asyncCompile ( docNames , token , flags )
272267 . then ( ( data ) => {
273268 const info = docs . length > 1 ? "" : `${ docs [ 0 ] . name } : ` ;
274269 if ( data . status && data . status . errors && data . status . errors . length ) {
275270 throw new Error ( `${ info } Compile error` ) ;
276271 } else if ( ! conf . get ( "suppressCompileMessages" ) ) {
277272 vscode . window . showInformationMessage ( `${ info } Compilation succeeded.` , "Dismiss" ) ;
278273 }
274+ if ( wsFolder ) {
275+ // Make sure that we update the content for any
276+ // other documents affected by this compilation
277+ data . result . content . forEach ( ( f ) => {
278+ if ( docNames . includes ( f . name ) ) return ;
279+ getUrisForDocument ( f . name , wsFolder ) . forEach ( ( u ) => {
280+ docs . push ( {
281+ name : f . name ,
282+ uri : u ,
283+ uniqueId : `${ wsFolder . name } :${ f . name } ` ,
284+ // These two keys aren't used by loadChanges()
285+ workspaceFolder : wsFolder . name ,
286+ fileName : u . fsPath ,
287+ } ) ;
288+ } ) ;
289+ } ) ;
290+ }
279291 return docs ;
280292 } )
281293 . catch ( ( ) => {
0 commit comments