@@ -60,6 +60,8 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
60
60
return this . _model ?. modified . notebook ;
61
61
}
62
62
63
+ private _revealFirst : boolean ;
64
+
63
65
constructor (
64
66
@IInstantiationService readonly instantiationService : IInstantiationService ,
65
67
@IThemeService readonly themeService : IThemeService ,
@@ -74,6 +76,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
74
76
super ( NotebookTextDiffEditor . ID , telemetryService , themeService , storageService ) ;
75
77
const editorOptions = this . configurationService . getValue < IEditorOptions > ( 'editor' ) ;
76
78
this . _fontInfo = BareFontInfo . createFromRawSettings ( editorOptions , getZoomLevel ( ) ) ;
79
+ this . _revealFirst = true ;
77
80
78
81
this . _register ( this . _modifiedResourceDisposableStore ) ;
79
82
}
@@ -152,6 +155,8 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
152
155
return ;
153
156
}
154
157
158
+ this . _revealFirst = true ;
159
+
155
160
this . _modifiedResourceDisposableStore . add ( this . _fileService . watch ( this . _model . modified . resource ) ) ;
156
161
this . _modifiedResourceDisposableStore . add ( this . _fileService . onDidFilesChange ( async e => {
157
162
if ( this . _model === null ) {
@@ -223,6 +228,8 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
223
228
let originalCellIndex = 0 ;
224
229
let modifiedCellIndex = 0 ;
225
230
231
+ let firstChangeIndex = - 1 ;
232
+
226
233
for ( let i = 0 ; i < cellChanges . length ; i ++ ) {
227
234
const change = cellChanges [ i ] ;
228
235
// common cells
@@ -238,6 +245,10 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
238
245
this . _eventDispatcher !
239
246
) ) ;
240
247
} else {
248
+ if ( firstChangeIndex === - 1 ) {
249
+ firstChangeIndex = cellDiffViewModels . length ;
250
+ }
251
+
241
252
cellDiffViewModels . push ( new CellDiffViewModel (
242
253
originalCell ,
243
254
modifiedCell ,
@@ -247,7 +258,12 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
247
258
}
248
259
}
249
260
250
- cellDiffViewModels . push ( ...this . _computeModifiedLCS ( change , originalModel , modifiedModel ) ) ;
261
+ const modifiedLCS = this . _computeModifiedLCS ( change , originalModel , modifiedModel ) ;
262
+ if ( modifiedLCS . length && firstChangeIndex === - 1 ) {
263
+ firstChangeIndex = cellDiffViewModels . length ;
264
+ }
265
+
266
+ cellDiffViewModels . push ( ...modifiedLCS ) ;
251
267
originalCellIndex = change . originalStart + change . originalLength ;
252
268
modifiedCellIndex = change . modifiedStart + change . modifiedLength ;
253
269
}
@@ -262,6 +278,12 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
262
278
}
263
279
264
280
this . _list . splice ( 0 , this . _list . length , cellDiffViewModels ) ;
281
+
282
+ if ( this . _revealFirst && firstChangeIndex !== - 1 ) {
283
+ this . _revealFirst = false ;
284
+ this . _list . setFocus ( [ firstChangeIndex ] ) ;
285
+ this . _list . reveal ( firstChangeIndex , 0.3 ) ;
286
+ }
265
287
}
266
288
267
289
private _computeModifiedLCS ( change : IDiffChange , originalModel : NotebookTextModel , modifiedModel : NotebookTextModel ) {
0 commit comments