@@ -11,6 +11,7 @@ import { Action } from 'vs/base/common/actions';
11
11
import { Codicon } from 'vs/base/common/codicons' ;
12
12
import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
13
13
import { Disposable } from 'vs/base/common/lifecycle' ;
14
+ import { IObservable , observableValue } from 'vs/base/common/observable' ;
14
15
import { ThemeIcon } from 'vs/base/common/themables' ;
15
16
import { Constants } from 'vs/base/common/uint' ;
16
17
import { applyFontInfo } from 'vs/editor/browser/config/domFontInfo' ;
@@ -85,7 +86,7 @@ export class DiffReview2 extends Disposable {
85
86
private static _ttPolicy = DiffReview . _ttPolicy ; // TODO inline once DiffReview is deprecated.
86
87
87
88
private readonly _diffEditor : DiffEditorWidget2 ;
88
- private _isVisible : boolean ;
89
+ private get _isVisible ( ) { return this . _isVisibleObs . get ( ) ; }
89
90
public readonly shadow : FastDomNode < HTMLElement > ;
90
91
private readonly _actionBar : ActionBar ;
91
92
public readonly actionBarContainer : FastDomNode < HTMLElement > ;
@@ -95,6 +96,10 @@ export class DiffReview2 extends Disposable {
95
96
private _diffs : Diff [ ] ;
96
97
private _currentDiff : Diff | null ;
97
98
99
+ private readonly _isVisibleObs = observableValue ( 'isVisible' , false ) ;
100
+
101
+ public readonly isVisible : IObservable < boolean > = this . _isVisibleObs ;
102
+
98
103
constructor (
99
104
diffEditor : DiffEditorWidget2 ,
100
105
@ILanguageService private readonly _languageService : ILanguageService ,
@@ -103,7 +108,6 @@ export class DiffReview2 extends Disposable {
103
108
) {
104
109
super ( ) ;
105
110
this . _diffEditor = diffEditor ;
106
- this . _isVisible = false ;
107
111
108
112
this . shadow = createFastDomNode ( document . createElement ( 'div' ) ) ;
109
113
this . shadow . setClassName ( 'diff-review-shadow' ) ;
@@ -215,7 +219,7 @@ export class DiffReview2 extends Disposable {
215
219
const entries = this . _diffs [ index ] . entries ;
216
220
this . _diffEditor . setPosition ( new Position ( entries [ 0 ] . modifiedLineStart , 1 ) ) ;
217
221
this . _diffEditor . setSelection ( { startColumn : 1 , startLineNumber : entries [ 0 ] . modifiedLineStart , endColumn : Constants . MAX_SAFE_SMALL_INTEGER , endLineNumber : entries [ entries . length - 1 ] . modifiedLineEnd } ) ;
218
- this . _isVisible = true ;
222
+ this . _isVisibleObs . set ( true , undefined ) ;
219
223
this . layout ( ) ;
220
224
this . _render ( ) ;
221
225
this . _goToRow ( this . _getPrevRow ( ) , 'previous' ) ;
@@ -250,7 +254,7 @@ export class DiffReview2 extends Disposable {
250
254
const entries = this . _diffs [ index ] . entries ;
251
255
this . _diffEditor . setPosition ( new Position ( entries [ 0 ] . modifiedLineStart , 1 ) ) ;
252
256
this . _diffEditor . setSelection ( { startColumn : 1 , startLineNumber : entries [ 0 ] . modifiedLineStart , endColumn : Constants . MAX_SAFE_SMALL_INTEGER , endLineNumber : entries [ entries . length - 1 ] . modifiedLineEnd } ) ;
253
- this . _isVisible = true ;
257
+ this . _isVisibleObs . set ( true , undefined ) ;
254
258
this . layout ( ) ;
255
259
this . _render ( ) ;
256
260
this . _goToRow ( this . _getNextRow ( ) , 'next' ) ;
@@ -274,8 +278,7 @@ export class DiffReview2 extends Disposable {
274
278
}
275
279
276
280
private hide ( ) : void {
277
- this . _isVisible = false ;
278
- this . _diffEditor . updateOptions ( { readOnly : false } ) ;
281
+ this . _isVisibleObs . set ( false , undefined ) ;
279
282
this . _diffEditor . focus ( ) ;
280
283
this . layout ( ) ;
281
284
this . _render ( ) ;
@@ -331,10 +334,6 @@ export class DiffReview2 extends Disposable {
331
334
this . scrollbar . scanDomNode ( ) ;
332
335
}
333
336
334
- public isVisible ( ) : boolean {
335
- return this . _isVisible ;
336
- }
337
-
338
337
private _width : number = 0 ;
339
338
private _top : number = 0 ;
340
339
private _height : number = 0 ;
@@ -564,7 +563,6 @@ export class DiffReview2 extends Disposable {
564
563
return ;
565
564
}
566
565
567
- this . _diffEditor . updateOptions ( { readOnly : true } ) ;
568
566
const diffIndex = this . _findDiffIndex ( this . _diffEditor . getPosition ( ) ! ) ;
569
567
570
568
if ( this . _diffs [ diffIndex ] === this . _currentDiff ) {
0 commit comments