@@ -981,44 +981,54 @@ export function registerCommands(
981981 return { thread, text } ;
982982 }
983983
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 ) {
986986 /* __GDPR__
987987 "pr.resolveReviewThread" : {}
988988 */
989989 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+ }
992996
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 ;
9951002 }
996- } ) ,
997- ) ;
1003+ commentLike = activeHandler . commentController . activeCommentThread as vscode . CommentThread2 as GHPRCommentThread ;
1004+ }
9981005
999- const unresolve = async ( commentLike : CommentReply | GHPRCommentThread | GHPRComment , focusReply : boolean ) => {
1000- /* __GDPR__
1001- "pr.unresolveReviewThread" : {}
1002- */
1003- telemetry . sendTelemetryEvent ( 'pr.unresolveReviewThread' ) ;
10041006 const { thread, text } = threadAndText ( commentLike ) ;
10051007
10061008 const handler = resolveCommentHandler ( thread ) ;
10071009
10081010 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+ }
10121018 }
10131019 }
10141020 } ;
10151021
10161022 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 ) )
10181028 ) ;
10191029
10201030 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 ) )
10221032 ) ;
10231033
10241034 const localUriFromReviewUri = ( reviewUri : vscode . Uri ) => {
0 commit comments