@@ -16,6 +16,7 @@ import { IViewZone } from 'vs/editor/browser/editorBrowser';
16
16
import { StableEditorScrollState } from 'vs/editor/browser/stableEditorScroll' ;
17
17
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget' ;
18
18
import { diffDeleteDecoration , diffRemoveIcon } from 'vs/editor/browser/widget/diffEditorWidget2/decorations' ;
19
+ import { DiffEditorEditors } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorEditors' ;
19
20
import { DiffEditorViewModel , DiffMapping } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorViewModel' ;
20
21
import { DiffEditorWidget2 } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2' ;
21
22
import { InlineDiffDeletedCodeMargin } from 'vs/editor/browser/widget/diffEditorWidget2/inlineDiffDeletedCodeMargin' ;
@@ -49,8 +50,7 @@ export class ViewZoneManager extends Disposable {
49
50
private readonly _modifiedScrollOffsetAnimated = animatedObservable ( this . _modifiedScrollOffset , this . _store ) ;
50
51
51
52
constructor (
52
- private readonly _originalEditor : CodeEditorWidget ,
53
- private readonly _modifiedEditor : CodeEditorWidget ,
53
+ private readonly _editors : DiffEditorEditors ,
54
54
private readonly _diffModel : IObservable < DiffEditorViewModel | undefined > ,
55
55
private readonly _options : DiffEditorOptions ,
56
56
private readonly _diffEditorWidget : DiffEditorWidget2 ,
@@ -64,11 +64,11 @@ export class ViewZoneManager extends Disposable {
64
64
65
65
const originalViewZonesChanged = observableSignalFromEvent (
66
66
'origViewZonesChanged' ,
67
- e => this . _originalEditor . onDidChangeViewZones ( ( args ) => { if ( ! isChangingViewZones && ! this . _canIgnoreViewZoneUpdateEvent ( ) ) { e ( args ) ; } } )
67
+ e => this . _editors . original . onDidChangeViewZones ( ( args ) => { if ( ! isChangingViewZones && ! this . _canIgnoreViewZoneUpdateEvent ( ) ) { e ( args ) ; } } )
68
68
) ;
69
69
const modifiedViewZonesChanged = observableSignalFromEvent (
70
70
'modViewZonesChanged' ,
71
- e => this . _modifiedEditor . onDidChangeViewZones ( ( args ) => { if ( ! isChangingViewZones && ! this . _canIgnoreViewZoneUpdateEvent ( ) ) { e ( args ) ; } } )
71
+ e => this . _editors . modified . onDidChangeViewZones ( ( args ) => { if ( ! isChangingViewZones && ! this . _canIgnoreViewZoneUpdateEvent ( ) ) { e ( args ) ; } } )
72
72
) ;
73
73
74
74
const originalModelTokenizationCompleted = this . _diffModel . map ( m =>
@@ -84,7 +84,7 @@ export class ViewZoneManager extends Disposable {
84
84
if ( ! diffModel || ! diff ) { return null ; }
85
85
originalViewZonesChanged . read ( reader ) ;
86
86
modifiedViewZonesChanged . read ( reader ) ;
87
- return computeRangeAlignment ( this . _originalEditor , this . _modifiedEditor , diff . mappings , alignmentViewZoneIdsOrig , alignmentViewZoneIdsMod ) ;
87
+ return computeRangeAlignment ( this . _editors . original , this . _editors . modified , diff . mappings , alignmentViewZoneIdsOrig , alignmentViewZoneIdsMod ) ;
88
88
} ) ;
89
89
90
90
const alignmentsSyncedMovedText = derived < ILineRangeAlignment [ ] | null > ( 'alignments' , ( reader ) => {
@@ -94,7 +94,7 @@ export class ViewZoneManager extends Disposable {
94
94
modifiedViewZonesChanged . read ( reader ) ;
95
95
const mappings = syncedMovedText . changes . map ( c => new DiffMapping ( c ) ) ;
96
96
// TODO dont include alignments outside syncedMovedText
97
- return computeRangeAlignment ( this . _originalEditor , this . _modifiedEditor , mappings , alignmentViewZoneIdsOrig , alignmentViewZoneIdsMod ) ;
97
+ return computeRangeAlignment ( this . _editors . original , this . _editors . modified , mappings , alignmentViewZoneIdsOrig , alignmentViewZoneIdsMod ) ;
98
98
} ) ;
99
99
100
100
function createFakeLinesDiv ( ) : HTMLElement {
@@ -133,12 +133,12 @@ export class ViewZoneManager extends Disposable {
133
133
134
134
const renderSideBySide = this . _options . renderSideBySide . read ( reader ) ;
135
135
136
- const deletedCodeLineBreaksComputer = ! renderSideBySide ? this . _modifiedEditor . _getViewModel ( ) ?. createLineBreaksComputer ( ) : undefined ;
136
+ const deletedCodeLineBreaksComputer = ! renderSideBySide ? this . _editors . modified . _getViewModel ( ) ?. createLineBreaksComputer ( ) : undefined ;
137
137
if ( deletedCodeLineBreaksComputer ) {
138
138
for ( const a of alignmentsVal ) {
139
139
if ( a . diff ) {
140
140
for ( let i = a . originalRange . startLineNumber ; i < a . originalRange . endLineNumberExclusive ; i ++ ) {
141
- deletedCodeLineBreaksComputer ?. addRequest ( this . _originalEditor . getModel ( ) ! . getLineContent ( i ) , null , null ) ;
141
+ deletedCodeLineBreaksComputer ?. addRequest ( this . _editors . original . getModel ( ) ! . getLineContent ( i ) , null , null ) ;
142
142
}
143
143
}
144
144
}
@@ -147,13 +147,13 @@ export class ViewZoneManager extends Disposable {
147
147
const lineBreakData = deletedCodeLineBreaksComputer ?. finalize ( ) ?? [ ] ;
148
148
let lineBreakDataIdx = 0 ;
149
149
150
- const modLineHeight = this . _modifiedEditor . getOption ( EditorOption . lineHeight ) ;
150
+ const modLineHeight = this . _editors . modified . getOption ( EditorOption . lineHeight ) ;
151
151
152
152
const syncedMovedText = this . _diffModel . read ( reader ) ?. syncedMovedTexts . read ( reader ) ;
153
153
154
- const mightContainNonBasicASCII = this . _originalEditor . getModel ( ) ?. mightContainNonBasicASCII ( ) ?? false ;
155
- const mightContainRTL = this . _originalEditor . getModel ( ) ?. mightContainRTL ( ) ?? false ;
156
- const renderOptions = RenderOptions . fromEditor ( this . _modifiedEditor ) ;
154
+ const mightContainNonBasicASCII = this . _editors . original . getModel ( ) ?. mightContainNonBasicASCII ( ) ?? false ;
155
+ const mightContainRTL = this . _editors . original . getModel ( ) ?. mightContainRTL ( ) ?? false ;
156
+ const renderOptions = RenderOptions . fromEditor ( this . _editors . modified ) ;
157
157
158
158
for ( const a of alignmentsVal ) {
159
159
if ( a . diff && ! renderSideBySide ) {
@@ -163,7 +163,7 @@ export class ViewZoneManager extends Disposable {
163
163
const deletedCodeDomNode = document . createElement ( 'div' ) ;
164
164
deletedCodeDomNode . classList . add ( 'view-lines' , 'line-delete' , 'monaco-mouse-cursor-text' ) ;
165
165
const source = new LineSource (
166
- a . originalRange . mapToLineArray ( l => this . _originalEditor . getModel ( ) ! . tokenization . getLineTokens ( l ) ) ,
166
+ a . originalRange . mapToLineArray ( l => this . _editors . original . getModel ( ) ! . tokenization . getLineTokens ( l ) ) ,
167
167
a . originalRange . mapToLineArray ( _ => lineBreakData [ lineBreakDataIdx ++ ] ) ,
168
168
mightContainNonBasicASCII ,
169
169
mightContainRTL ,
@@ -196,11 +196,11 @@ export class ViewZoneManager extends Disposable {
196
196
new InlineDiffDeletedCodeMargin (
197
197
( ) => assertIsDefined ( zoneId ) ,
198
198
marginDomNode ,
199
- this . _modifiedEditor ,
199
+ this . _editors . modified ,
200
200
a . diff ,
201
201
this . _diffEditorWidget ,
202
202
result . viewLineCounts ,
203
- this . _originalEditor . getModel ( ) ! ,
203
+ this . _editors . original . getModel ( ) ! ,
204
204
this . _contextMenuService ,
205
205
this . _clipboardService ,
206
206
)
@@ -309,11 +309,11 @@ export class ViewZoneManager extends Disposable {
309
309
} ) ;
310
310
311
311
this . _register ( autorunWithStore2 ( 'alignment viewzones' , ( reader ) => {
312
- const scrollState = StableEditorScrollState . capture ( this . _modifiedEditor ) ;
312
+ const scrollState = StableEditorScrollState . capture ( this . _editors . modified ) ;
313
313
314
314
const alignmentViewZones_ = alignmentViewZones . read ( reader ) ;
315
315
isChangingViewZones = true ;
316
- this . _originalEditor . changeViewZones ( ( aOrig ) => {
316
+ this . _editors . original . changeViewZones ( ( aOrig ) => {
317
317
for ( const id of alignmentViewZoneIdsOrig ) { aOrig . removeZone ( id ) ; }
318
318
alignmentViewZoneIdsOrig . clear ( ) ;
319
319
for ( const z of alignmentViewZones_ . orig ) {
@@ -324,7 +324,7 @@ export class ViewZoneManager extends Disposable {
324
324
alignmentViewZoneIdsOrig . add ( id ) ;
325
325
}
326
326
} ) ;
327
- this . _modifiedEditor . changeViewZones ( aMod => {
327
+ this . _editors . modified . changeViewZones ( aMod => {
328
328
for ( const id of alignmentViewZoneIdsMod ) { aMod . removeZone ( id ) ; }
329
329
alignmentViewZoneIdsMod . clear ( ) ;
330
330
for ( const z of alignmentViewZones_ . mod ) {
@@ -337,27 +337,27 @@ export class ViewZoneManager extends Disposable {
337
337
} ) ;
338
338
isChangingViewZones = false ;
339
339
340
- scrollState . restore ( this . _modifiedEditor ) ;
340
+ scrollState . restore ( this . _editors . modified ) ;
341
341
} ) ) ;
342
342
343
343
let ignoreChange = false ;
344
- this . _register ( this . _originalEditor . onDidScrollChange ( e => {
344
+ this . _register ( this . _editors . original . onDidScrollChange ( e => {
345
345
if ( e . scrollLeftChanged && ! ignoreChange ) {
346
346
ignoreChange = true ;
347
- this . _modifiedEditor . setScrollLeft ( e . scrollLeft ) ;
347
+ this . _editors . modified . setScrollLeft ( e . scrollLeft ) ;
348
348
ignoreChange = false ;
349
349
}
350
350
} ) ) ;
351
- this . _register ( this . _modifiedEditor . onDidScrollChange ( e => {
351
+ this . _register ( this . _editors . modified . onDidScrollChange ( e => {
352
352
if ( e . scrollLeftChanged && ! ignoreChange ) {
353
353
ignoreChange = true ;
354
- this . _originalEditor . setScrollLeft ( e . scrollLeft ) ;
354
+ this . _editors . original . setScrollLeft ( e . scrollLeft ) ;
355
355
ignoreChange = false ;
356
356
}
357
357
} ) ) ;
358
358
359
- this . _originalScrollTop = observableFromEvent ( this . _originalEditor . onDidScrollChange , ( ) => this . _originalEditor . getScrollTop ( ) ) ;
360
- this . _modifiedScrollTop = observableFromEvent ( this . _modifiedEditor . onDidScrollChange , ( ) => this . _modifiedEditor . getScrollTop ( ) ) ;
359
+ this . _originalScrollTop = observableFromEvent ( this . _editors . original . onDidScrollChange , ( ) => this . _editors . original . getScrollTop ( ) ) ;
360
+ this . _modifiedScrollTop = observableFromEvent ( this . _editors . modified . onDidScrollChange , ( ) => this . _editors . modified . getScrollTop ( ) ) ;
361
361
362
362
// origExtraHeight + origOffset - origScrollTop = modExtraHeight + modOffset - modScrollTop
363
363
@@ -371,17 +371,17 @@ export class ViewZoneManager extends Disposable {
371
371
const newScrollTopModified = this . _originalScrollTop . read ( reader )
372
372
- ( this . _originalScrollOffsetAnimated . get ( ) - this . _modifiedScrollOffsetAnimated . read ( reader ) )
373
373
- ( this . _originalTopPadding . get ( ) - this . _modifiedTopPadding . read ( reader ) ) ;
374
- if ( newScrollTopModified !== this . _modifiedEditor . getScrollTop ( ) ) {
375
- this . _modifiedEditor . setScrollTop ( newScrollTopModified , ScrollType . Immediate ) ;
374
+ if ( newScrollTopModified !== this . _editors . modified . getScrollTop ( ) ) {
375
+ this . _editors . modified . setScrollTop ( newScrollTopModified , ScrollType . Immediate ) ;
376
376
}
377
377
} ) ) ;
378
378
379
379
this . _register ( autorun ( 'update scroll original' , ( reader ) => {
380
380
const newScrollTopOriginal = this . _modifiedScrollTop . read ( reader )
381
381
- ( this . _modifiedScrollOffsetAnimated . get ( ) - this . _originalScrollOffsetAnimated . read ( reader ) )
382
382
- ( this . _modifiedTopPadding . get ( ) - this . _originalTopPadding . read ( reader ) ) ;
383
- if ( newScrollTopOriginal !== this . _originalEditor . getScrollTop ( ) ) {
384
- this . _originalEditor . setScrollTop ( newScrollTopOriginal , ScrollType . Immediate ) ;
383
+ if ( newScrollTopOriginal !== this . _editors . original . getScrollTop ( ) ) {
384
+ this . _editors . original . setScrollTop ( newScrollTopOriginal , ScrollType . Immediate ) ;
385
385
}
386
386
} ) ) ;
387
387
@@ -391,8 +391,8 @@ export class ViewZoneManager extends Disposable {
391
391
392
392
let deltaOrigToMod = 0 ;
393
393
if ( m ) {
394
- const trueTopOriginal = this . _originalEditor . getTopForLineNumber ( m . lineRangeMapping . originalRange . startLineNumber , true ) - this . _originalTopPadding . get ( ) ;
395
- const trueTopModified = this . _modifiedEditor . getTopForLineNumber ( m . lineRangeMapping . modifiedRange . startLineNumber , true ) - this . _modifiedTopPadding . get ( ) ;
394
+ const trueTopOriginal = this . _editors . original . getTopForLineNumber ( m . lineRangeMapping . originalRange . startLineNumber , true ) - this . _originalTopPadding . get ( ) ;
395
+ const trueTopModified = this . _editors . modified . getTopForLineNumber ( m . lineRangeMapping . modifiedRange . startLineNumber , true ) - this . _modifiedTopPadding . get ( ) ;
396
396
deltaOrigToMod = trueTopModified - trueTopOriginal ;
397
397
}
398
398
@@ -409,7 +409,7 @@ export class ViewZoneManager extends Disposable {
409
409
} , 400 ) ;
410
410
}
411
411
412
- if ( this . _modifiedEditor . hasTextFocus ( ) ) {
412
+ if ( this . _editors . modified . hasTextFocus ( ) ) {
413
413
this . _originalScrollOffset . set ( this . _modifiedScrollOffset . get ( ) - deltaOrigToMod , undefined , true ) ;
414
414
} else {
415
415
this . _modifiedScrollOffset . set ( this . _originalScrollOffset . get ( ) + deltaOrigToMod , undefined , true ) ;
0 commit comments