From 5876f66f772a10edd33f18f43b5062d2ada31427 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Wed, 3 Apr 2019 18:32:00 -0700 Subject: [PATCH] Merge EmptyCommentThreadFactory with CommentingRangeProvider --- src/vs/vscode.proposed.d.ts | 7 ------- src/vs/workbench/api/node/extHostComments.ts | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 409a752ec8a..8b5d828e6eb 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1017,9 +1017,7 @@ declare module 'vscode' { * Provide a list of ranges which allow new comment threads creation or null for a given document */ provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult; - } - export interface EmptyCommentThreadFactory { /** * The method `createEmptyCommentThread` is called when users attempt to create new comment thread from the gutter or command palette. * Extensions still need to call `createCommentThread` inside this call when appropriate. @@ -1054,11 +1052,6 @@ declare module 'vscode' { */ commentingRangeProvider?: CommentingRangeProvider; - /** - * Optional new comment thread factory. - */ - emptyCommentThreadFactory?: EmptyCommentThreadFactory; - /** * Optional reaction provider */ diff --git a/src/vs/workbench/api/node/extHostComments.ts b/src/vs/workbench/api/node/extHostComments.ts index 859b593566f..e3d728774d5 100644 --- a/src/vs/workbench/api/node/extHostComments.ts +++ b/src/vs/workbench/api/node/extHostComments.ts @@ -149,12 +149,25 @@ export class ExtHostComments implements ExtHostCommentsShape { $createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): Promise { const commentController = this._commentControllers.get(commentControllerHandle); - if (!commentController || !commentController.emptyCommentThreadFactory) { + if (!commentController) { + return Promise.resolve(); + } + + if (!(commentController as any).emptyCommentThreadFactory && !(commentController.commentingRangeProvider && commentController.commentingRangeProvider.createEmptyCommentThread)) { return Promise.resolve(); } const document = this._documents.getDocument(URI.revive(uriComponents)); - return asPromise(() => commentController.emptyCommentThreadFactory!.createEmptyCommentThread(document, extHostTypeConverter.Range.to(range))).then(() => Promise.resolve()); + return asPromise(() => { + // TODO, remove this once GH PR stable deprecates `emptyCommentThreadFactory`. + if ((commentController as any).emptyCommentThreadFactory) { + return (commentController as any).emptyCommentThreadFactory!.createEmptyCommentThread(document, extHostTypeConverter.Range.to(range)); + } + + if (commentController.commentingRangeProvider && commentController.commentingRangeProvider.createEmptyCommentThread) { + return commentController.commentingRangeProvider.createEmptyCommentThread(document, extHostTypeConverter.Range.to(range)); + } + }).then(() => Promise.resolve()); } registerWorkspaceCommentProvider( @@ -558,8 +571,6 @@ class ExtHostCommentController implements vscode.CommentController { private _threads: Map = new Map(); commentingRangeProvider?: vscode.CommentingRangeProvider; - emptyCommentThreadFactory?: vscode.EmptyCommentThreadFactory; - private _commentReactionProvider?: vscode.CommentReactionProvider;