From 58730f32797a4789eeeb788628c22fe9c5b27f4b Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Wed, 10 Jul 2024 12:32:28 +0200 Subject: [PATCH] Update use of comment thread reveal proposal (#6085) Part of microsoft/vscode#167253 --- package.json | 2 +- src/@types/vscode.proposed.commentReveal.d.ts | 31 +++++++++++++------ src/@types/vscode.proposed.fileComments.d.ts | 3 -- src/commands.ts | 2 +- src/github/prComment.ts | 2 +- src/test/view/reviewCommentController.test.ts | 1 + 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 0f408577..e818a464 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "version": "0.92.0", "publisher": "GitHub", "engines": { - "vscode": "^1.91.0" + "vscode": "^1.92.0" }, "categories": [ "Other" diff --git a/src/@types/vscode.proposed.commentReveal.d.ts b/src/@types/vscode.proposed.commentReveal.d.ts index 168c4691..3aa005d0 100644 --- a/src/@types/vscode.proposed.commentReveal.d.ts +++ b/src/@types/vscode.proposed.commentReveal.d.ts @@ -7,26 +7,39 @@ declare module 'vscode' { // @alexr00 https://github.com/microsoft/vscode/issues/167253 + export enum CommentThreadFocus { + /** + * Focus the comment editor if the thread supports replying. + */ + Reply = 1, + /** + * Focus the revealed comment. + */ + Comment = 2 + } + /** * Options to reveal a comment thread in an editor. */ export interface CommentThreadRevealOptions { - /** - * By default, the comment thread will be focused. Set `preserveFocus` to `true` to maintain the original focus. - */ - preserveFocus?: boolean; /** - * Focus the comment thread reply editor, if the thread supports replying. + * Where to move the focus to when revealing the comment thread. + * If undefined, the focus will not be changed. */ - focusReply?: boolean; + focus?: CommentThreadFocus; } - export interface CommentThread { + export interface CommentThread2 { /** - * Reveal the comment thread in an editor. + * Reveal the comment thread in an editor. If no comment is provided, the first comment in the thread will be revealed. */ - reveal(options?: CommentThreadRevealOptions): Thenable; + reveal(comment?: Comment, options?: CommentThreadRevealOptions): Thenable; + + /** + * Collapse the comment thread in an editor. + */ + hide(): Thenable; } } diff --git a/src/@types/vscode.proposed.fileComments.d.ts b/src/@types/vscode.proposed.fileComments.d.ts index 963b91bf..65ebaefc 100644 --- a/src/@types/vscode.proposed.fileComments.d.ts +++ b/src/@types/vscode.proposed.fileComments.d.ts @@ -68,9 +68,6 @@ declare module 'vscode' { * Once disposed, this comment thread will be removed from visible editors and Comment Panel when appropriate. */ dispose(): void; - - // Part of the comment reveal proposal - reveal(options?: CommentThreadRevealOptions): Thenable; } export interface CommentController { diff --git a/src/commands.ts b/src/commands.ts index 319ab779..497930bb 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -974,7 +974,7 @@ export function registerCommands( if (handler) { await handler.unresolveReviewThread(thread, text); if (focusReply) { - thread.reveal({ focusReply: true }); + thread.reveal(undefined, { focus: vscode.CommentThreadFocus.Reply }); } } }; diff --git a/src/github/prComment.ts b/src/github/prComment.ts index 3e76887e..2ce62e72 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -48,7 +48,7 @@ export interface GHPRCommentThread extends vscode.CommentThread2 { */ state?: { resolved: vscode.CommentThreadState; applicability?: vscode.CommentThreadApplicability }; - reveal(options?: vscode.CommentThreadRevealOptions): Promise; + reveal(comment?: vscode.Comment, options?: vscode.CommentThreadRevealOptions): Promise; dispose: () => void; } diff --git a/src/test/view/reviewCommentController.test.ts b/src/test/view/reviewCommentController.test.ts index 68f6ee13..91ebc1bc 100644 --- a/src/test/view/reviewCommentController.test.ts +++ b/src/test/view/reviewCommentController.test.ts @@ -161,6 +161,7 @@ describe('ReviewCommentController', function () { state: { resolved: vscode.CommentThreadState.Unresolved, applicability: 0 }, canReply: false, reveal: () => Promise.resolve(), + hide: () => Promise.resolve(), dispose: () => { }, }; }