@@ -43,6 +43,7 @@ import URI from 'vs/base/common/uri';
4343import { IStringBuilder , createStringBuilder } from 'vs/editor/common/core/stringBuilder' ;
4444import { IModelDeltaDecoration , IModelDecorationsChangeAccessor , ITextModel } from 'vs/editor/common/model' ;
4545import { INotificationService } from 'vs/platform/notification/common/notification' ;
46+ import { StableEditorScrollState } from 'vs/editor/browser/core/editorState' ;
4647
4748interface IEditorDiffDecorations {
4849 decorations : IModelDeltaDecoration [ ] ;
@@ -102,7 +103,10 @@ class VisualEditorState {
102103 this . _decorations = editor . deltaDecorations ( this . _decorations , [ ] ) ;
103104 }
104105
105- public apply ( editor : CodeEditor , overviewRuler : editorBrowser . IOverviewRuler , newDecorations : IEditorDiffDecorationsWithZones ) : void {
106+ public apply ( editor : CodeEditor , overviewRuler : editorBrowser . IOverviewRuler , newDecorations : IEditorDiffDecorationsWithZones , restoreScrollState : boolean ) : void {
107+
108+ const scrollState = restoreScrollState ? StableEditorScrollState . capture ( editor ) : null ;
109+
106110 // view zones
107111 editor . changeViewZones ( ( viewChangeAccessor : editorBrowser . IViewZoneChangeAccessor ) => {
108112 for ( let i = 0 , length = this . _zones . length ; i < length ; i ++ ) {
@@ -118,6 +122,10 @@ class VisualEditorState {
118122 }
119123 } ) ;
120124
125+ if ( scrollState ) {
126+ scrollState . restore ( editor ) ;
127+ }
128+
121129 // decorations
122130 this . _decorations = editor . deltaDecorations ( this . _decorations , newDecorations . decorations ) ;
123131
@@ -916,8 +924,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
916924
917925 try {
918926 this . _currentlyChangingViewZones = true ;
919- this . _originalEditorState . apply ( this . originalEditor , this . _originalOverviewRuler , diffDecorations . original ) ;
920- this . _modifiedEditorState . apply ( this . modifiedEditor , this . _modifiedOverviewRuler , diffDecorations . modified ) ;
927+ this . _originalEditorState . apply ( this . originalEditor , this . _originalOverviewRuler , diffDecorations . original , false ) ;
928+ this . _modifiedEditorState . apply ( this . modifiedEditor , this . _modifiedOverviewRuler , diffDecorations . modified , true ) ;
921929 } finally {
922930 this . _currentlyChangingViewZones = false ;
923931 }
0 commit comments