@@ -67,9 +67,15 @@ export class PlainTextDiff extends Widget implements Git.Diff.IDiffWidget {
67
67
* is attached so CodeMirror get proper size.
68
68
*/
69
69
onAfterAttach ( ) : void {
70
- this . createDiffView ( ) . catch ( reason => {
71
- this . showError ( reason ) ;
72
- } ) ;
70
+ this . ready
71
+ . then ( ( ) => {
72
+ if ( this . _challenger !== null && this . _reference !== null ) {
73
+ this . createDiffView ( this . _challenger , this . _reference ) ;
74
+ }
75
+ } )
76
+ . catch ( reason => {
77
+ this . showError ( reason ) ;
78
+ } ) ;
73
79
}
74
80
75
81
/**
@@ -90,8 +96,18 @@ export class PlainTextDiff extends Widget implements Git.Diff.IDiffWidget {
90
96
// Clear all
91
97
this . _container . innerHTML = '' ;
92
98
this . _mergeView = null ;
99
+
93
100
// ENH request content only if it changed
94
- this . createDiffView ( ) ;
101
+ if ( this . _reference !== null ) {
102
+ this . _reference = await this . _model . reference . content ( ) ;
103
+ }
104
+ if ( this . _challenger !== null ) {
105
+ this . _challenger = await this . _model . challenger . content ( ) ;
106
+ }
107
+
108
+ this . createDiffView ( this . _challenger , this . _reference ) ;
109
+ this . _challenger = null ;
110
+ this . _reference = null ;
95
111
} catch ( reason ) {
96
112
this . showError ( reason ) ;
97
113
}
@@ -119,31 +135,24 @@ export class PlainTextDiff extends Widget implements Git.Diff.IDiffWidget {
119
135
/**
120
136
* Create the Plain Text Diff view
121
137
*/
122
- protected async createDiffView ( ) : Promise < void > {
138
+ protected async createDiffView (
139
+ challengerContent : string ,
140
+ referenceContent : string
141
+ ) : Promise < void > {
123
142
if ( ! this . _mergeView ) {
124
143
const mode =
125
144
Mode . findByFileName ( this . _model . filename ) ||
126
145
Mode . findBest ( this . _model . filename ) ;
127
146
128
- await this . ready ;
129
-
130
- if ( ! this . _reference ) {
131
- this . _reference = await this . _model . reference . content ( ) ;
132
- }
133
- if ( ! this . _challenger ) {
134
- this . _challenger = await this . _model . challenger . content ( ) ;
135
- }
136
-
137
147
this . _mergeView = mergeView ( this . _container , {
138
- value : this . _challenger ,
139
- orig : this . _reference ,
148
+ value : challengerContent ,
149
+ orig : referenceContent ,
140
150
mode : mode . mime ,
141
- ...PlainTextDiff . getDefaultOptions ( )
151
+ ...this . getDefaultOptions ( )
142
152
} ) as MergeView . MergeViewEditor ;
143
-
144
- this . _reference = null ;
145
- this . _challenger = null ;
146
153
}
154
+
155
+ return Promise . resolve ( ) ;
147
156
}
148
157
149
158
/**
@@ -164,7 +173,7 @@ export class PlainTextDiff extends Widget implements Git.Diff.IDiffWidget {
164
173
</p>` ;
165
174
}
166
175
167
- protected static getDefaultOptions ( ) : Partial < MergeView . MergeViewEditorConfiguration > {
176
+ protected getDefaultOptions ( ) : Partial < MergeView . MergeViewEditorConfiguration > {
168
177
// FIXME add options from settings and connect settings to update options
169
178
return {
170
179
lineNumbers : true ,
0 commit comments