diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index c7c7abb3a3b..45331fd2e37 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1062,6 +1062,12 @@ declare module 'vscode' { */ readonly inputBox: CommentInputBox | undefined; + /** + * The active [comment thread](#CommentThread) or `undefined`. The `activeCommentThread` is the comment thread of + * the comment thread widget that currently has focus. It's `undefined` when the focus is not in any comment thread widget. + */ + readonly activeCommentThread: CommentThread | undefined; + /** * Create a [CommentThread](#CommentThread). The comment thread will be displayed in visible text editors (if the resource matches) * and Comments Panel. diff --git a/src/vs/workbench/api/browser/mainThreadComments.ts b/src/vs/workbench/api/browser/mainThreadComments.ts index 7fb1f2c50b0..f7e791f868e 100644 --- a/src/vs/workbench/api/browser/mainThreadComments.ts +++ b/src/vs/workbench/api/browser/mainThreadComments.ts @@ -458,6 +458,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments this._proxy.$onCommentWidgetInputChange(controller.handle, this._input ? this._input.value : undefined); })); + await this._proxy.$onActiveCommentThreadChange(controller.handle, controller.activeCommentThread.commentThreadHandle); await this._proxy.$onCommentWidgetInputChange(controller.handle, this._input ? this._input.value : undefined); })); } diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 0515075538c..bc847725bb6 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1203,6 +1203,7 @@ export interface ExtHostCommentsShape { $provideDocumentComments(handle: number, document: UriComponents): Promise; $createNewCommentThread(handle: number, document: UriComponents, range: IRange, text: string): Promise; $onCommentWidgetInputChange(commentControllerHandle: number, input: string | undefined): Promise; + $onActiveCommentThreadChange(commentControllerHandle: number, threadHandle: number | undefined): Promise; $provideCommentingRanges(commentControllerHandle: number, uriComponents: UriComponents, token: CancellationToken): Promise; $provideReactionGroup(commentControllerHandle: number): Promise; $toggleReaction(commentControllerHandle: number, threadHandle: number, uri: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise; diff --git a/src/vs/workbench/api/common/extHostComments.ts b/src/vs/workbench/api/common/extHostComments.ts index c22b84a8c19..5fd8d420b23 100644 --- a/src/vs/workbench/api/common/extHostComments.ts +++ b/src/vs/workbench/api/common/extHostComments.ts @@ -99,6 +99,17 @@ export class ExtHostComments implements ExtHostCommentsShape { return Promise.resolve(commentControllerHandle); } + $onActiveCommentThreadChange(commentControllerHandle: number, threadHandle: number): Promise { + const commentController = this._commentControllers.get(commentControllerHandle); + + if (!commentController) { + return Promise.resolve(undefined); + } + + commentController.$onActiveCommentThreadChange(threadHandle); + return Promise.resolve(threadHandle); + } + $provideCommentingRanges(commentControllerHandle: number, uriComponents: UriComponents, token: CancellationToken): Promise { const commentController = this._commentControllers.get(commentControllerHandle); @@ -563,6 +574,7 @@ class ExtHostCommentController implements vscode.CommentController { } public inputBox: ExtHostCommentInputBox | undefined; + public activeCommentThread: ExtHostCommentThread | undefined; public activeCommentingRange?: vscode.Range; public get handle(): number { @@ -610,6 +622,10 @@ class ExtHostCommentController implements vscode.CommentController { } } + $onActiveCommentThreadChange(threadHandle: number) { + this.activeCommentThread = this.getCommentThread(threadHandle); + } + getCommentThread(handle: number) { return this._threads.get(handle); }