@@ -981,44 +981,54 @@ export function registerCommands(
981
981
return { thread, text } ;
982
982
}
983
983
984
- context . subscriptions . push (
985
- vscode . commands . registerCommand ( 'pr.resolveReviewThread' , async ( commentLike : CommentReply | GHPRCommentThread | GHPRComment ) => {
984
+ const resolve = async ( commentLike : CommentReply | GHPRCommentThread | GHPRComment | undefined , resolve : boolean , focusReply ?: boolean ) => {
985
+ if ( resolve ) {
986
986
/* __GDPR__
987
987
"pr.resolveReviewThread" : {}
988
988
*/
989
989
telemetry . sendTelemetryEvent ( 'pr.resolveReviewThread' ) ;
990
- const { thread, text } = threadAndText ( commentLike ) ;
991
- const handler = resolveCommentHandler ( thread ) ;
990
+ } else {
991
+ /* __GDPR__
992
+ "pr.unresolveReviewThread" : {}
993
+ */
994
+ telemetry . sendTelemetryEvent ( 'pr.unresolveReviewThread' ) ;
995
+ }
992
996
993
- if ( handler ) {
994
- await handler . resolveReviewThread ( thread , text ) ;
997
+ if ( ! commentLike ) {
998
+ const activeHandler = findActiveHandler ( ) ;
999
+ if ( ! activeHandler ) {
1000
+ vscode . window . showErrorMessage ( vscode . l10n . t ( 'No active comment thread found' ) ) ;
1001
+ return ;
995
1002
}
996
- } ) ,
997
- ) ;
1003
+ commentLike = activeHandler . commentController . activeCommentThread as vscode . CommentThread2 as GHPRCommentThread ;
1004
+ }
998
1005
999
- const unresolve = async ( commentLike : CommentReply | GHPRCommentThread | GHPRComment , focusReply : boolean ) => {
1000
- /* __GDPR__
1001
- "pr.unresolveReviewThread" : {}
1002
- */
1003
- telemetry . sendTelemetryEvent ( 'pr.unresolveReviewThread' ) ;
1004
1006
const { thread, text } = threadAndText ( commentLike ) ;
1005
1007
1006
1008
const handler = resolveCommentHandler ( thread ) ;
1007
1009
1008
1010
if ( handler ) {
1009
- await handler . unresolveReviewThread ( thread , text ) ;
1010
- if ( focusReply ) {
1011
- thread . reveal ( undefined , { focus : vscode . CommentThreadFocus . Reply } ) ;
1011
+ if ( resolve ) {
1012
+ await handler . resolveReviewThread ( thread , text ) ;
1013
+ } else {
1014
+ await handler . unresolveReviewThread ( thread , text ) ;
1015
+ if ( focusReply ) {
1016
+ thread . reveal ( undefined , { focus : vscode . CommentThreadFocus . Reply } ) ;
1017
+ }
1012
1018
}
1013
1019
}
1014
1020
} ;
1015
1021
1016
1022
context . subscriptions . push (
1017
- vscode . commands . registerCommand ( 'pr.unresolveReviewThread' , ( commentLike : CommentReply | GHPRCommentThread | GHPRComment ) => unresolve ( commentLike , false ) )
1023
+ vscode . commands . registerCommand ( 'pr.resolveReviewThread' , async ( commentLike : CommentReply | GHPRCommentThread | GHPRComment ) => resolve ( commentLike , true ) )
1024
+ ) ;
1025
+
1026
+ context . subscriptions . push (
1027
+ vscode . commands . registerCommand ( 'pr.unresolveReviewThread' , ( commentLike : CommentReply | GHPRCommentThread | GHPRComment ) => resolve ( commentLike , false , false ) )
1018
1028
) ;
1019
1029
1020
1030
context . subscriptions . push (
1021
- vscode . commands . registerCommand ( 'pr.unresolveReviewThreadFromView' , ( commentLike : CommentReply | GHPRCommentThread | GHPRComment ) => unresolve ( commentLike , true ) )
1031
+ vscode . commands . registerCommand ( 'pr.unresolveReviewThreadFromView' , ( commentLike : CommentReply | GHPRCommentThread | GHPRComment ) => resolve ( commentLike , false , true ) )
1022
1032
) ;
1023
1033
1024
1034
const localUriFromReviewUri = ( reviewUri : vscode . Uri ) => {
0 commit comments