File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ export class CodeProject {
118118
119119 callbackBuildResult : BuildResultCallback ;
120120 callbackBuildStatus : BuildStatusCallback ;
121+ onFileChanged : ( path : string , data : FileData ) => void ;
121122
122123 constructor ( worker , platform_id : string , platform , filesystem : ProjectFilesystem ) {
123124 this . worker = worker ;
@@ -128,6 +129,16 @@ export class CodeProject {
128129 worker . onmessage = ( e ) => {
129130 this . receiveWorkerMessage ( e . data ) ;
130131 } ;
132+
133+ filesystem . onFileSystemUpdate ( async ( path : string ) => {
134+ if ( path in this . filedata ) {
135+ var data = await this . filesystem . getFileData ( path ) ;
136+ if ( data ) {
137+ this . updateFile ( path , data ) ;
138+ if ( this . onFileChanged ) this . onFileChanged ( path , data ) ;
139+ }
140+ }
141+ } ) ;
131142 }
132143
133144 receiveWorkerMessage ( data : WorkerResult ) {
Original file line number Diff line number Diff line change @@ -261,6 +261,19 @@ async function initProject() {
261261 current_project . callbackBuildStatus = ( busy : boolean ) => {
262262 setBusyStatus ( busy ) ;
263263 } ;
264+ // Update views when file contents change.
265+ current_project . onFileChanged = ( path : string , data : FileData ) => {
266+ var wnd = projectWindows . id2window [ path ] ;
267+ if ( wnd ) {
268+ if ( wnd instanceof SourceEditor && typeof data === 'string' ) {
269+ wnd . setText ( data ) ;
270+ } else if ( wnd instanceof BinaryFileView && data instanceof Uint8Array ) {
271+ wnd . setData ( data ) ;
272+ } else {
273+ console . warn ( 'onFileChanged: unknown view or data type' ) ;
274+ }
275+ }
276+ } ;
264277}
265278
266279function setBusyStatus ( busy : boolean ) {
You can’t perform that action at this time.
0 commit comments