@@ -187,39 +187,58 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
187
187
}
188
188
189
189
public reveal ( commentUniqueId ?: number , focus : CommentWidgetFocus = CommentWidgetFocus . None ) {
190
+ this . makeVisible ( commentUniqueId , focus ) ;
191
+ const comment = this . _commentThread . comments ?. find ( comment => comment . uniqueIdInThread === commentUniqueId ) ;
192
+ this . commentService . setActiveCommentAndThread ( this . uniqueOwner , { thread : this . _commentThread , comment } ) ;
193
+ }
194
+
195
+ private _expandAndShowZoneWidget ( ) {
190
196
if ( ! this . _isExpanded ) {
191
197
this . show ( this . arrowPosition ( this . _commentThread . range ) , 2 ) ;
192
198
}
199
+ }
193
200
194
- if ( commentUniqueId !== undefined ) {
195
- const height = this . editor . getLayoutInfo ( ) . height ;
196
- const coords = this . _commentThreadWidget . getCommentCoords ( commentUniqueId ) ;
197
- if ( coords ) {
198
- let scrollTop : number = 1 ;
199
- if ( this . _commentThread . range ) {
200
- const commentThreadCoords = coords . thread ;
201
- const commentCoords = coords . comment ;
202
- scrollTop = this . editor . getTopForLineNumber ( this . _commentThread . range . startLineNumber ) - height / 2 + commentCoords . top - commentThreadCoords . top ;
203
- }
204
- this . editor . setScrollTop ( scrollTop ) ;
205
- if ( focus === CommentWidgetFocus . Widget ) {
206
- this . _commentThreadWidget . focus ( ) ;
207
- } else if ( focus === CommentWidgetFocus . Editor ) {
208
- this . _commentThreadWidget . focusCommentEditor ( ) ;
209
- }
210
- return ;
201
+ private _setFocus ( focus : CommentWidgetFocus ) {
202
+ if ( focus === CommentWidgetFocus . Widget ) {
203
+ this . _commentThreadWidget . focus ( ) ;
204
+ } else if ( focus === CommentWidgetFocus . Editor ) {
205
+ this . _commentThreadWidget . focusCommentEditor ( ) ;
206
+ }
207
+ }
208
+
209
+ private _goToComment ( commentUniqueId : number , focus : CommentWidgetFocus ) {
210
+ const height = this . editor . getLayoutInfo ( ) . height ;
211
+ const coords = this . _commentThreadWidget . getCommentCoords ( commentUniqueId ) ;
212
+ if ( coords ) {
213
+ let scrollTop : number = 1 ;
214
+ if ( this . _commentThread . range ) {
215
+ const commentThreadCoords = coords . thread ;
216
+ const commentCoords = coords . comment ;
217
+ scrollTop = this . editor . getTopForLineNumber ( this . _commentThread . range . startLineNumber ) - height / 2 + commentCoords . top - commentThreadCoords . top ;
211
218
}
219
+ this . editor . setScrollTop ( scrollTop ) ;
220
+ this . _setFocus ( focus ) ;
221
+ } else {
222
+ this . _goToThread ( focus ) ;
212
223
}
224
+ }
225
+
226
+ private _goToThread ( focus : CommentWidgetFocus ) {
213
227
const rangeToReveal = this . _commentThread . range
214
228
? new Range ( this . _commentThread . range . startLineNumber , this . _commentThread . range . startColumn , this . _commentThread . range . endLineNumber + 1 , 1 )
215
229
: new Range ( 1 , 1 , 1 , 1 ) ;
216
230
217
231
this . editor . revealRangeInCenter ( rangeToReveal ) ;
218
- if ( focus === CommentWidgetFocus . Widget ) {
219
- this . _commentThreadWidget . focus ( ) ;
220
- } else if ( focus === CommentWidgetFocus . Editor ) {
221
- this . _commentThreadWidget . focusCommentEditor ( ) ;
232
+ this . _setFocus ( focus ) ;
233
+ }
234
+
235
+ public makeVisible ( commentUniqueId ?: number , focus : CommentWidgetFocus = CommentWidgetFocus . None ) {
236
+ this . _expandAndShowZoneWidget ( ) ;
237
+
238
+ if ( commentUniqueId !== undefined ) {
239
+ this . _goToComment ( commentUniqueId , focus ) ;
222
240
}
241
+ this . _goToThread ( focus ) ;
223
242
}
224
243
225
244
public getPendingComments ( ) : { newComment : string | undefined ; edits : { [ key : number ] : string } } {
@@ -371,7 +390,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
371
390
372
391
// If this is a new comment thread awaiting user input then we need to reveal it.
373
392
if ( shouldReveal ) {
374
- this . reveal ( ) ;
393
+ this . makeVisible ( ) ;
375
394
}
376
395
377
396
this . bindCommentThreadListeners ( ) ;
0 commit comments