mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
API to find the active comment thread (#204486)
* API to find the active comment thread Fixes #204484 * Add issue ref * Add activeComment proposal to api tests * Add settimeout to blur event
This commit is contained in:
@@ -168,6 +168,16 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
commentController.$createCommentThreadTemplate(uriComponents, range);
|
||||
}
|
||||
|
||||
async $setActiveComment(controllerHandle: number, commentInfo: { commentThreadHandle: number; uniqueIdInThread?: number }): Promise<void> {
|
||||
const commentController = this._commentControllers.get(controllerHandle);
|
||||
|
||||
if (!commentController) {
|
||||
return;
|
||||
}
|
||||
|
||||
commentController.$setActiveComment(commentInfo ?? undefined);
|
||||
}
|
||||
|
||||
async $updateCommentThreadTemplate(commentControllerHandle: number, threadHandle: number, range: IRange) {
|
||||
const commentController = this._commentControllers.get(commentControllerHandle);
|
||||
|
||||
@@ -582,6 +592,19 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
proxy.$updateCommentControllerFeatures(this.handle, { options: this._options });
|
||||
}
|
||||
|
||||
private _activeComment: vscode.Comment | undefined;
|
||||
|
||||
get activeComment(): vscode.Comment | undefined {
|
||||
checkProposedApiEnabled(this._extension, 'activeComment');
|
||||
return this._activeComment;
|
||||
}
|
||||
|
||||
private _activeThread: vscode.CommentThread2 | undefined;
|
||||
|
||||
get activeThread(): vscode.CommentThread2 | undefined {
|
||||
checkProposedApiEnabled(this._extension, 'activeComment');
|
||||
return this._activeThread;
|
||||
}
|
||||
|
||||
private _localDisposables: types.Disposable[];
|
||||
readonly value: vscode.CommentController;
|
||||
@@ -604,6 +627,8 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
set commentingRangeProvider(commentingRangeProvider: vscode.CommentingRangeProvider | undefined) { that.commentingRangeProvider = commentingRangeProvider; },
|
||||
get reactionHandler(): ReactionHandler | undefined { return that.reactionHandler; },
|
||||
set reactionHandler(handler: ReactionHandler | undefined) { that.reactionHandler = handler; },
|
||||
// get activeComment(): vscode.Comment | undefined { return that.activeComment; },
|
||||
get activeThread(): vscode.CommentThread2 | undefined { return that.activeThread; },
|
||||
createCommentThread(uri: vscode.Uri, range: vscode.Range | undefined, comments: vscode.Comment[]): vscode.CommentThread | vscode.CommentThread2 {
|
||||
return that.createCommentThread(uri, range, comments).value;
|
||||
},
|
||||
@@ -627,6 +652,19 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
return commentThread;
|
||||
}
|
||||
|
||||
$setActiveComment(commentInfo: { commentThreadHandle: number; uniqueIdInThread?: number } | undefined) {
|
||||
if (!commentInfo) {
|
||||
this._activeComment = undefined;
|
||||
this._activeThread = undefined;
|
||||
return;
|
||||
}
|
||||
const thread = this._threads.get(commentInfo.commentThreadHandle);
|
||||
if (thread) {
|
||||
this._activeComment = commentInfo.uniqueIdInThread ? thread.getCommentByUniqueId(commentInfo.uniqueIdInThread) : undefined;
|
||||
this._activeThread = thread;
|
||||
}
|
||||
}
|
||||
|
||||
$createCommentThreadTemplate(uriComponents: UriComponents, range: IRange | undefined): ExtHostCommentThread {
|
||||
const commentThread = new ExtHostCommentThread(this.id, this.handle, undefined, URI.revive(uriComponents), extHostTypeConverter.Range.to(range), [], this._extension, true);
|
||||
commentThread.collapsibleState = languages.CommentThreadCollapsibleState.Expanded;
|
||||
|
||||
Reference in New Issue
Block a user