Update commenting api

This commit is contained in:
Peng Lyu
2019-04-05 11:59:10 -07:00
parent 2b169fc0ad
commit b9ad2eb3bf
2 changed files with 3 additions and 13 deletions

View File

@ -15,13 +15,10 @@ export function activate(context: vscode.ExtensionContext) {
provideCommentingRanges: (document: vscode.TextDocument, token: vscode.CancellationToken) => {
let lineCount = document.lineCount;
return [new vscode.Range(0, 0, lineCount - 1, 0)];
}
};
// callback when users click `+` button on Gutter or run Create Comment command from Command Palette
commentController.emptyCommentThreadFactory = {
},
// callback when users click `+` button on Gutter or run Create Comment command from Command Palette
createEmptyCommentThread: (document: vscode.TextDocument, range: vscode.Range) => {
// create a empty thread
// create a empty thread
let thread = commentController.createCommentThread(`${++threadId}`, document.uri, range, []);
// by default, a comment thread is collapsed, for newly created empty comment thread, we want to expand it and users can start commenting immediately
thread.collapsibleState = vscode.CommentThreadCollapsibleState.Expanded;

View File

@ -155,9 +155,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<Range[]>;
}
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.
@ -192,11 +190,6 @@ declare module 'vscode' {
*/
commentingRangeProvider?: CommentingRangeProvider;
/**
* Optional new comment thread factory.
*/
emptyCommentThreadFactory?: EmptyCommentThreadFactory;
/**
* Dispose this comment controller.
*/