Add a command for deleting comment threads

This commit is contained in:
Rachel Macfarlane
2019-03-18 16:27:18 -07:00
parent 37cb23d3dd
commit 30b2c30706
6 changed files with 78 additions and 8 deletions

View File

@@ -142,6 +142,14 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
return this._additionalCommands;
}
set deleteCommand(newCommand: modes.Command) {
this._deleteCommand = newCommand;
}
get deleteCommand(): modes.Command {
return this._deleteCommand;
}
private _onDidChangeAdditionalCommands = new Emitter<modes.Command[]>();
get onDidChangeAdditionalCommands(): Event<modes.Command[]> { return this._onDidChangeAdditionalCommands.event; }
@@ -179,6 +187,7 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
private _comments: modes.Comment[],
private _acceptInputCommand: modes.Command | undefined,
private _additionalCommands: modes.Command[],
private _deleteCommand: modes.Command | undefined,
private _collapsibleState: modes.CommentThreadCollapsibleState
) {
@@ -240,7 +249,15 @@ export class MainThreadCommentController {
this._features = features;
}
createCommentThread(commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], acceptInputCommand: modes.Command | undefined, additionalCommands: modes.Command[], collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 {
createCommentThread(commentThreadHandle: number,
threadId: string,
resource: UriComponents,
range: IRange,
comments: modes.Comment[],
acceptInputCommand: modes.Command | undefined,
additionalCommands: modes.Command[],
deleteCommand: modes.Command | undefined,
collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 {
let thread = new MainThreadCommentThread(
commentThreadHandle,
this,
@@ -251,6 +268,7 @@ export class MainThreadCommentController {
comments,
acceptInputCommand,
additionalCommands,
deleteCommand,
collapseState
);
@@ -301,6 +319,11 @@ export class MainThreadCommentController {
thread.additionalCommands = additionalCommands;
}
updateDeleteCommand(commentThreadHandle: number, deleteCommand: modes.Command) {
const thread = this.getKnownThread(commentThreadHandle);
thread.deleteCommand = deleteCommand;
}
updateCollapsibleState(commentThreadHandle: number, collapseState: modes.CommentThreadCollapsibleState) {
let thread = this.getKnownThread(commentThreadHandle);
thread.collapsibleState = collapseState;
@@ -326,7 +349,7 @@ export class MainThreadCommentController {
}
}
private getKnownThread(commentThreadHandle: number) {
private getKnownThread(commentThreadHandle: number): MainThreadCommentThread {
const thread = this._threads.get(commentThreadHandle);
if (!thread) {
throw new Error('unknown thread');
@@ -468,14 +491,23 @@ export class MainThreadComments extends Disposable implements MainThreadComments
provider.updateFeatures(features);
}
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], acceptInputCommand: modes.Command | undefined, additionalCommands: modes.Command[], collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 | undefined {
$createCommentThread(handle: number,
commentThreadHandle: number,
threadId: string,
resource: UriComponents,
range: IRange,
comments: modes.Comment[],
acceptInputCommand: modes.Command | undefined,
additionalCommands: modes.Command[],
deleteCommand: modes.Command,
collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 | undefined {
let provider = this._commentControllers.get(handle);
if (!provider) {
return undefined;
}
return provider.createCommentThread(commentThreadHandle, threadId, resource, range, comments, acceptInputCommand, additionalCommands, collapseState);
return provider.createCommentThread(commentThreadHandle, threadId, resource, range, comments, acceptInputCommand, additionalCommands, deleteCommand, collapseState);
}
$deleteCommentThread(handle: number, commentThreadHandle: number) {
@@ -528,6 +560,16 @@ export class MainThreadComments extends Disposable implements MainThreadComments
provider.updateAdditionalCommands(commentThreadHandle, additionalCommands);
}
$updateCommentThreadDeleteCommand(handle: number, commentThreadHandle: number, acceptInputCommand: modes.Command) {
let provider = this._commentControllers.get(handle);
if (!provider) {
return;
}
provider.updateDeleteCommand(commentThreadHandle, acceptInputCommand);
}
$updateCommentThreadCollapsibleState(handle: number, commentThreadHandle: number, collapseState: modes.CommentThreadCollapsibleState): void {
let provider = this._commentControllers.get(handle);

View File

@@ -123,12 +123,13 @@ export interface MainThreadCommentsShape extends IDisposable {
$registerCommentController(handle: number, id: string, label: string): void;
$unregisterCommentController(handle: number): void;
$updateCommentControllerFeatures(handle: number, features: CommentProviderFeatures): void;
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], acceptInputCommand: modes.Command | undefined, additionalCommands: modes.Command[], collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 | undefined;
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], acceptInputCommand: modes.Command | undefined, additionalCommands: modes.Command[], deleteCommand: modes.Command | undefined, collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 | undefined;
$deleteCommentThread(handle: number, commentThreadHandle: number): void;
$updateComments(handle: number, commentThreadHandle: number, comments: modes.Comment[]): void;
$setInputValue(handle: number, input: string): void;
$updateCommentThreadAcceptInputCommand(handle: number, commentThreadHandle: number, acceptInputCommand: modes.Command): void;
$updateCommentThreadAdditionalCommands(handle: number, commentThreadHandle: number, additionalCommands: modes.Command[]): void;
$updateCommentThreadDeleteCommand(handle: number, commentThreadHandle: number, deleteCommand: modes.Command): void;
$updateCommentThreadCollapsibleState(handle: number, commentThreadHandle: number, collapseState: modes.CommentThreadCollapsibleState): void;
$updateCommentThreadRange(handle: number, commentThreadHandle: number, range: IRange): void;
$updateCommentThreadLabel(handle: number, commentThreadHandle: number, label: string): void;

View File

@@ -415,6 +415,18 @@ export class ExtHostCommentThread implements vscode.CommentThread {
this._proxy.$updateCommentThreadAdditionalCommands(this._commentController.handle, this.handle, internals);
}
private _deleteCommand?: vscode.Command;
get deleteComand(): vscode.Command | undefined {
return this._deleteCommand;
}
set deleteCommand(deleteCommand: vscode.Command) {
this._deleteCommand = deleteCommand;
const internal = this._commandsConverter.toInternal(deleteCommand);
this._proxy.$updateCommentThreadDeleteCommand(this._commentController.handle, this.handle, internal);
}
private _collapseState?: vscode.CommentThreadCollapsibleState;
get collapsibleState(): vscode.CommentThreadCollapsibleState {
@@ -444,6 +456,7 @@ export class ExtHostCommentThread implements vscode.CommentThread {
this._comments.map(comment => { return convertToModeComment(this._commentController, comment, this._commandsConverter); }),
this._acceptInputCommand ? this._commandsConverter.toInternal(this._acceptInputCommand) : undefined,
this._additionalCommands ? this._additionalCommands.map(x => this._commandsConverter.toInternal(x)) : [],
this._deleteCommand ? this._commandsConverter.toInternal(this._deleteCommand) : undefined,
this._collapseState!
);
}