@@ -24,6 +24,7 @@ import { createActionViewItem } from 'vs/platform/actions/browser/menuEntryActio
24
24
export class TemplateData implements IObjectData {
25
25
constructor (
26
26
public readonly viewModel : DocumentDiffItemViewModel ,
27
+ public readonly deltaScrollVertical : ( delta : number ) => void ,
27
28
) { }
28
29
29
30
@@ -116,15 +117,15 @@ export class DiffEditorItemTemplate extends Disposable implements IPooledObject<
116
117
this . _elements . editor . style . display = this . _collapsed . read ( reader ) ? 'none' : 'block' ;
117
118
} ) ) ;
118
119
119
- this . editor . getModifiedEditor ( ) . onDidLayoutChange ( e => {
120
+ this . _register ( this . editor . getModifiedEditor ( ) . onDidLayoutChange ( e => {
120
121
const width = this . editor . getModifiedEditor ( ) . getLayoutInfo ( ) . contentWidth ;
121
122
this . _modifiedWidth . set ( width , undefined ) ;
122
- } ) ;
123
+ } ) ) ;
123
124
124
- this . editor . getOriginalEditor ( ) . onDidLayoutChange ( e => {
125
+ this . _register ( this . editor . getOriginalEditor ( ) . onDidLayoutChange ( e => {
125
126
const width = this . editor . getOriginalEditor ( ) . getLayoutInfo ( ) . contentWidth ;
126
127
this . _originalWidth . set ( width , undefined ) ;
127
- } ) ;
128
+ } ) ) ;
128
129
129
130
this . _register ( this . editor . onDidContentSizeChange ( e => {
130
131
globalTransaction ( tx => {
@@ -134,6 +135,18 @@ export class DiffEditorItemTemplate extends Disposable implements IPooledObject<
134
135
} ) ;
135
136
} ) ) ;
136
137
138
+ this . _register ( this . editor . getOriginalEditor ( ) . onDidScrollChange ( e => {
139
+ if ( this . _isSettingScrollTop ) {
140
+ return ;
141
+ }
142
+
143
+ if ( ! e . scrollTopChanged || ! this . _data ) {
144
+ return ;
145
+ }
146
+ const delta = e . scrollTop - this . _lastScrollTop ;
147
+ this . _data . deltaScrollVertical ( delta ) ;
148
+ } ) ) ;
149
+
137
150
this . _register ( autorun ( reader => {
138
151
const isFocused = this . isFocused . read ( reader ) ;
139
152
this . _elements . root . classList . toggle ( 'focused' , isFocused ) ;
@@ -162,7 +175,10 @@ export class DiffEditorItemTemplate extends Disposable implements IPooledObject<
162
175
163
176
private readonly _dataStore = new DisposableStore ( ) ;
164
177
178
+ private _data : TemplateData | undefined ;
179
+
165
180
public setData ( data : TemplateData ) : void {
181
+ this . _data = data ;
166
182
function updateOptions ( options : IDiffEditorOptions ) : IDiffEditorOptions {
167
183
return {
168
184
...options ,
@@ -222,6 +238,9 @@ export class DiffEditorItemTemplate extends Disposable implements IPooledObject<
222
238
223
239
private readonly _headerHeight = /*this._elements.header.clientHeight*/ 48 ;
224
240
241
+ private _lastScrollTop = - 1 ;
242
+ private _isSettingScrollTop = false ;
243
+
225
244
public render ( verticalRange : OffsetRange , width : number , editorScroll : number , viewPort : OffsetRange ) : void {
226
245
this . _elements . root . style . visibility = 'visible' ;
227
246
this . _elements . root . style . top = `${ verticalRange . start } px` ;
@@ -240,7 +259,13 @@ export class DiffEditorItemTemplate extends Disposable implements IPooledObject<
240
259
height : verticalRange . length - this . _outerEditorHeight ,
241
260
} ) ;
242
261
} ) ;
243
- this . editor . getOriginalEditor ( ) . setScrollTop ( editorScroll ) ;
262
+ try {
263
+ this . _isSettingScrollTop = true ;
264
+ this . _lastScrollTop = editorScroll ;
265
+ this . editor . getOriginalEditor ( ) . setScrollTop ( editorScroll ) ;
266
+ } finally {
267
+ this . _isSettingScrollTop = false ;
268
+ }
244
269
245
270
this . _elements . header . classList . toggle ( 'shadow' , delta > 0 || editorScroll > 0 ) ;
246
271
this . _elements . header . classList . toggle ( 'collapsed' , delta === maxDelta ) ;
0 commit comments