@@ -27,10 +27,12 @@ import { getZoomLevel } from 'vs/base/browser/browser';
2727import { NotebookLayoutInfo } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
2828import { DIFF_CELL_MARGIN , INotebookTextDiffEditor } from 'vs/workbench/contrib/notebook/browser/diff/common' ;
2929import { Emitter } from 'vs/base/common/event' ;
30- import { IDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
30+ import { DisposableStore , IDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
3131import { NotebookDiffEditorEventDispatcher , NotebookLayoutChangedEvent } from 'vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher' ;
3232import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane' ;
3333import { INotebookDiffEditorModel } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
34+ import { FileService } from 'vs/platform/files/common/fileService' ;
35+ import { IFileService } from 'vs/platform/files/common/files' ;
3436
3537export const IN_NOTEBOOK_TEXT_DIFF_EDITOR = new RawContextKey < boolean > ( 'isInNotebookTextDiffEditor' , false ) ;
3638
@@ -48,6 +50,8 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
4850 private _eventDispatcher : NotebookDiffEditorEventDispatcher | undefined ;
4951 protected _scopeContextKeyService ! : IContextKeyService ;
5052 private _model : INotebookDiffEditorModel | null = null ;
53+ private _modifiedResourceDisposableStore = new DisposableStore ( ) ;
54+
5155 get textModel ( ) {
5256 return this . _model ?. modified . notebook ;
5357 }
@@ -58,6 +62,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
5862 @IContextKeyService readonly contextKeyService : IContextKeyService ,
5963 @INotebookEditorWorkerService readonly notebookEditorWorkerService : INotebookEditorWorkerService ,
6064 @IConfigurationService private readonly configurationService : IConfigurationService ,
65+ @IFileService private readonly _fileService : FileService ,
6166
6267 @ITelemetryService telemetryService : ITelemetryService ,
6368 @IStorageService storageService : IStorageService ,
@@ -142,7 +147,34 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
142147 return ;
143148 }
144149
150+ this . _modifiedResourceDisposableStore . add ( this . _fileService . watch ( this . _model . modified . resource ) ) ;
151+ this . _modifiedResourceDisposableStore . add ( this . _fileService . onDidFilesChange ( async e => {
152+ if ( this . _model === null ) {
153+ return ;
154+ }
155+
156+ if ( e . changes . find ( change => change . resource . toString ( ) === this . _model ! . modified . resource . toString ( ) ) ) {
157+ await this . _model . resolveModifiedFromDisk ( ) ;
158+ await this . updateLayout ( ) ;
159+ return ;
160+ }
161+
162+ if ( e . changes . find ( change => change . resource . toString ( ) === this . _model ! . original . resource . toString ( ) ) ) {
163+ await this . _model . resolveOriginalFromDisk ( ) ;
164+ await this . updateLayout ( ) ;
165+ return ;
166+ }
167+ } ) ) ;
168+
169+
145170 this . _eventDispatcher = new NotebookDiffEditorEventDispatcher ( ) ;
171+ await this . updateLayout ( ) ;
172+ }
173+
174+ async updateLayout ( ) {
175+ if ( ! this . _model ) {
176+ return ;
177+ }
146178
147179 const diffResult = await this . notebookEditorWorkerService . computeDiff ( this . _model . original . resource , this . _model . modified . resource ) ;
148180 const cellChanges = diffResult . cellsDiff . changes ;
0 commit comments