@@ -16,6 +16,7 @@ import { IViewZone } from 'vs/editor/browser/editorBrowser';
1616import { StableEditorScrollState } from 'vs/editor/browser/stableEditorScroll' ;
1717import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget' ;
1818import { diffDeleteDecoration , diffRemoveIcon } from 'vs/editor/browser/widget/diffEditorWidget2/decorations' ;
19+ import { DiffEditorEditors } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorEditors' ;
1920import { DiffEditorViewModel , DiffMapping } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorViewModel' ;
2021import { DiffEditorWidget2 } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2' ;
2122import { InlineDiffDeletedCodeMargin } from 'vs/editor/browser/widget/diffEditorWidget2/inlineDiffDeletedCodeMargin' ;
@@ -49,8 +50,7 @@ export class ViewZoneManager extends Disposable {
4950 private readonly _modifiedScrollOffsetAnimated = animatedObservable ( this . _modifiedScrollOffset , this . _store ) ;
5051
5152 constructor (
52- private readonly _originalEditor : CodeEditorWidget ,
53- private readonly _modifiedEditor : CodeEditorWidget ,
53+ private readonly _editors : DiffEditorEditors ,
5454 private readonly _diffModel : IObservable < DiffEditorViewModel | undefined > ,
5555 private readonly _options : DiffEditorOptions ,
5656 private readonly _diffEditorWidget : DiffEditorWidget2 ,
@@ -64,11 +64,11 @@ export class ViewZoneManager extends Disposable {
6464
6565 const originalViewZonesChanged = observableSignalFromEvent (
6666 '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 ) ; } } )
6868 ) ;
6969 const modifiedViewZonesChanged = observableSignalFromEvent (
7070 '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 ) ; } } )
7272 ) ;
7373
7474 const originalModelTokenizationCompleted = this . _diffModel . map ( m =>
@@ -84,7 +84,7 @@ export class ViewZoneManager extends Disposable {
8484 if ( ! diffModel || ! diff ) { return null ; }
8585 originalViewZonesChanged . read ( reader ) ;
8686 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 ) ;
8888 } ) ;
8989
9090 const alignmentsSyncedMovedText = derived < ILineRangeAlignment [ ] | null > ( 'alignments' , ( reader ) => {
@@ -94,7 +94,7 @@ export class ViewZoneManager extends Disposable {
9494 modifiedViewZonesChanged . read ( reader ) ;
9595 const mappings = syncedMovedText . changes . map ( c => new DiffMapping ( c ) ) ;
9696 // 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 ) ;
9898 } ) ;
9999
100100 function createFakeLinesDiv ( ) : HTMLElement {
@@ -133,12 +133,12 @@ export class ViewZoneManager extends Disposable {
133133
134134 const renderSideBySide = this . _options . renderSideBySide . read ( reader ) ;
135135
136- const deletedCodeLineBreaksComputer = ! renderSideBySide ? this . _modifiedEditor . _getViewModel ( ) ?. createLineBreaksComputer ( ) : undefined ;
136+ const deletedCodeLineBreaksComputer = ! renderSideBySide ? this . _editors . modified . _getViewModel ( ) ?. createLineBreaksComputer ( ) : undefined ;
137137 if ( deletedCodeLineBreaksComputer ) {
138138 for ( const a of alignmentsVal ) {
139139 if ( a . diff ) {
140140 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 ) ;
142142 }
143143 }
144144 }
@@ -147,13 +147,13 @@ export class ViewZoneManager extends Disposable {
147147 const lineBreakData = deletedCodeLineBreaksComputer ?. finalize ( ) ?? [ ] ;
148148 let lineBreakDataIdx = 0 ;
149149
150- const modLineHeight = this . _modifiedEditor . getOption ( EditorOption . lineHeight ) ;
150+ const modLineHeight = this . _editors . modified . getOption ( EditorOption . lineHeight ) ;
151151
152152 const syncedMovedText = this . _diffModel . read ( reader ) ?. syncedMovedTexts . read ( reader ) ;
153153
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 ) ;
157157
158158 for ( const a of alignmentsVal ) {
159159 if ( a . diff && ! renderSideBySide ) {
@@ -163,7 +163,7 @@ export class ViewZoneManager extends Disposable {
163163 const deletedCodeDomNode = document . createElement ( 'div' ) ;
164164 deletedCodeDomNode . classList . add ( 'view-lines' , 'line-delete' , 'monaco-mouse-cursor-text' ) ;
165165 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 ) ) ,
167167 a . originalRange . mapToLineArray ( _ => lineBreakData [ lineBreakDataIdx ++ ] ) ,
168168 mightContainNonBasicASCII ,
169169 mightContainRTL ,
@@ -196,11 +196,11 @@ export class ViewZoneManager extends Disposable {
196196 new InlineDiffDeletedCodeMargin (
197197 ( ) => assertIsDefined ( zoneId ) ,
198198 marginDomNode ,
199- this . _modifiedEditor ,
199+ this . _editors . modified ,
200200 a . diff ,
201201 this . _diffEditorWidget ,
202202 result . viewLineCounts ,
203- this . _originalEditor . getModel ( ) ! ,
203+ this . _editors . original . getModel ( ) ! ,
204204 this . _contextMenuService ,
205205 this . _clipboardService ,
206206 )
@@ -309,11 +309,11 @@ export class ViewZoneManager extends Disposable {
309309 } ) ;
310310
311311 this . _register ( autorunWithStore2 ( 'alignment viewzones' , ( reader ) => {
312- const scrollState = StableEditorScrollState . capture ( this . _modifiedEditor ) ;
312+ const scrollState = StableEditorScrollState . capture ( this . _editors . modified ) ;
313313
314314 const alignmentViewZones_ = alignmentViewZones . read ( reader ) ;
315315 isChangingViewZones = true ;
316- this . _originalEditor . changeViewZones ( ( aOrig ) => {
316+ this . _editors . original . changeViewZones ( ( aOrig ) => {
317317 for ( const id of alignmentViewZoneIdsOrig ) { aOrig . removeZone ( id ) ; }
318318 alignmentViewZoneIdsOrig . clear ( ) ;
319319 for ( const z of alignmentViewZones_ . orig ) {
@@ -324,7 +324,7 @@ export class ViewZoneManager extends Disposable {
324324 alignmentViewZoneIdsOrig . add ( id ) ;
325325 }
326326 } ) ;
327- this . _modifiedEditor . changeViewZones ( aMod => {
327+ this . _editors . modified . changeViewZones ( aMod => {
328328 for ( const id of alignmentViewZoneIdsMod ) { aMod . removeZone ( id ) ; }
329329 alignmentViewZoneIdsMod . clear ( ) ;
330330 for ( const z of alignmentViewZones_ . mod ) {
@@ -337,27 +337,27 @@ export class ViewZoneManager extends Disposable {
337337 } ) ;
338338 isChangingViewZones = false ;
339339
340- scrollState . restore ( this . _modifiedEditor ) ;
340+ scrollState . restore ( this . _editors . modified ) ;
341341 } ) ) ;
342342
343343 let ignoreChange = false ;
344- this . _register ( this . _originalEditor . onDidScrollChange ( e => {
344+ this . _register ( this . _editors . original . onDidScrollChange ( e => {
345345 if ( e . scrollLeftChanged && ! ignoreChange ) {
346346 ignoreChange = true ;
347- this . _modifiedEditor . setScrollLeft ( e . scrollLeft ) ;
347+ this . _editors . modified . setScrollLeft ( e . scrollLeft ) ;
348348 ignoreChange = false ;
349349 }
350350 } ) ) ;
351- this . _register ( this . _modifiedEditor . onDidScrollChange ( e => {
351+ this . _register ( this . _editors . modified . onDidScrollChange ( e => {
352352 if ( e . scrollLeftChanged && ! ignoreChange ) {
353353 ignoreChange = true ;
354- this . _originalEditor . setScrollLeft ( e . scrollLeft ) ;
354+ this . _editors . original . setScrollLeft ( e . scrollLeft ) ;
355355 ignoreChange = false ;
356356 }
357357 } ) ) ;
358358
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 ( ) ) ;
361361
362362 // origExtraHeight + origOffset - origScrollTop = modExtraHeight + modOffset - modScrollTop
363363
@@ -371,17 +371,17 @@ export class ViewZoneManager extends Disposable {
371371 const newScrollTopModified = this . _originalScrollTop . read ( reader )
372372 - ( this . _originalScrollOffsetAnimated . get ( ) - this . _modifiedScrollOffsetAnimated . read ( reader ) )
373373 - ( 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 ) ;
376376 }
377377 } ) ) ;
378378
379379 this . _register ( autorun ( 'update scroll original' , ( reader ) => {
380380 const newScrollTopOriginal = this . _modifiedScrollTop . read ( reader )
381381 - ( this . _modifiedScrollOffsetAnimated . get ( ) - this . _originalScrollOffsetAnimated . read ( reader ) )
382382 - ( 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 ) ;
385385 }
386386 } ) ) ;
387387
@@ -391,8 +391,8 @@ export class ViewZoneManager extends Disposable {
391391
392392 let deltaOrigToMod = 0 ;
393393 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 ( ) ;
396396 deltaOrigToMod = trueTopModified - trueTopOriginal ;
397397 }
398398
@@ -409,7 +409,7 @@ export class ViewZoneManager extends Disposable {
409409 } , 400 ) ;
410410 }
411411
412- if ( this . _modifiedEditor . hasTextFocus ( ) ) {
412+ if ( this . _editors . modified . hasTextFocus ( ) ) {
413413 this . _originalScrollOffset . set ( this . _modifiedScrollOffset . get ( ) - deltaOrigToMod , undefined , true ) ;
414414 } else {
415415 this . _modifiedScrollOffset . set ( this . _originalScrollOffset . get ( ) + deltaOrigToMod , undefined , true ) ;
0 commit comments