Support new comment thread creation.

This commit is contained in:
Peng Lyu
2019-02-22 16:46:49 -08:00
parent 08e5839db2
commit bb62f5036d
8 changed files with 118 additions and 50 deletions

View File

@@ -123,10 +123,10 @@ export interface MainThreadCommentsShape extends IDisposable {
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], commands: modes.Command[], collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 | undefined;
$deleteCommentThread(handle: number, commentThreadHandle: number): void;
$updateComments(handle: number, commentThreadHandle: number, comments: modes.Comment[]): void;
$createCommentingRanges(handle: number, commentingRangesHandle: number, resource: UriComponents, ranges: IRange[], commands: modes.Command[]): void;
$createCommentingRanges(handle: number, commentingRangesHandle: number, resource: UriComponents, ranges: IRange[], commands: modes.Command): void;
$deleteCommentingRanges(handle: number, commentingRangesHandle: number): void;
$updateCommentingRanges(handle: number, commentingRangesHandle: number, newRanges: IRange[]): void;
$updateCommentingRangesCommands(handle: number, commentingRangesHandle: number, acceptInputCommands: modes.Command[]): void;
$updateCommentingRangesCommands(handle: number, commentingRangesHandle: number, command: modes.Command): void;
$setInputValue(handle: number, commentThreadHandle: number, input: string): void;
$updateCommentThreadCommands(handle: number, commentThreadHandle: number, acceptInputCommands: modes.Command[]): void;
$registerDocumentCommentProvider(handle: number, features: CommentProviderFeatures): void;
@@ -1102,7 +1102,7 @@ export interface ExtHostCommentsShape {
$provideDocumentComments(handle: number, document: UriComponents): Promise<modes.CommentInfo>;
$createNewCommentThread(handle: number, document: UriComponents, range: IRange, text: string): Promise<modes.CommentThread>;
$onActiveCommentWidgetChange(commentControlhandle: number, commentThread: modes.CommentThread2, comment: modes.Comment | undefined, input: string): Promise<number | undefined>;
$onCommentWidgetInputChange(commentControlhandle: number, value: string): Promise<void>;
$onActiveCommentingRangeChange(commentControlhandle: number, range: IRange): void;
$replyToCommentThread(handle: number, document: UriComponents, range: IRange, commentThread: modes.CommentThread, text: string): Promise<modes.CommentThread>;
$editComment(handle: number, document: UriComponents, comment: modes.Comment, text: string): Promise<void>;
$deleteComment(handle: number, document: UriComponents, comment: modes.Comment): Promise<void>;

View File

@@ -109,6 +109,16 @@ export class ExtHostComments implements ExtHostCommentsShape {
return Promise.resolve(undefined);
}
$onActiveCommentingRangeChange(commentControlhandle: number, range: IRange) {
const commentControl = this._commentControls.get(commentControlhandle);
if (!commentControl) {
return;
}
commentControl.setActiveCommentingRange(extHostTypeConverter.Range.to(range));
}
registerWorkspaceCommentProvider(
extensionId: ExtensionIdentifier,
provider: vscode.WorkspaceCommentProvider
@@ -400,15 +410,15 @@ export class ExtHostCommentingRanges implements vscode.CommentingRanges {
this._proxy.$updateCommentingRanges(this._commentControlHandle, this.handle, this._ranges.map(extHostTypeConverter.Range.from));
}
get acceptInputCommands(): vscode.Command[] {
return this._acceptInputCommands;
get newCommentThreadCommand(): vscode.Command {
return this._command;
}
set acceptInputCommands(replyCommands: vscode.Command[]) {
this._acceptInputCommands = replyCommands;
set newCommentThreadCommand(command: vscode.Command) {
this._command = command;
const internals = replyCommands.map(this._commandsConverter.toInternal.bind(this._commandsConverter));
this._proxy.$updateCommentingRangesCommands(this._commentControlHandle, this.handle, internals);
const internal = this._commandsConverter.toInternal(command);
this._proxy.$updateCommentingRangesCommands(this._commentControlHandle, this.handle, internal);
}
constructor(
@@ -417,14 +427,14 @@ export class ExtHostCommentingRanges implements vscode.CommentingRanges {
private _commentControlHandle: number,
private _resource: vscode.Uri,
private _ranges: vscode.Range[],
private _acceptInputCommands: vscode.Command[],
private _command: vscode.Command,
) {
this._proxy.$createCommentingRanges(
this._commentControlHandle,
this.handle,
this._resource,
this._ranges.map(extHostTypeConverter.Range.from),
this._acceptInputCommands.map(this._commandsConverter.toInternal.bind(this._commandsConverter))
this._commandsConverter.toInternal(this._command)
);
}
@@ -443,6 +453,7 @@ class ExtHostCommentControl implements vscode.CommentControl {
}
public widget?: ExtHostCommentWidget;
public activeCommentingRange?: vscode.Range;
public get handle(): number {
return this._handle;
@@ -482,12 +493,16 @@ class ExtHostCommentControl implements vscode.CommentControl {
this.widget = extHostCommentWidget;
}
createCommentingRanges(resource: vscode.Uri, ranges: vscode.Range[], acceptInputCommands: vscode.Command[]): vscode.CommentingRanges {
const commentingRange = new ExtHostCommentingRanges(this._proxy, this._commandsConverter, this.handle, resource, ranges, acceptInputCommands);
createCommentingRanges(resource: vscode.Uri, ranges: vscode.Range[], newCommentThreadCommand: vscode.Command): vscode.CommentingRanges {
const commentingRange = new ExtHostCommentingRanges(this._proxy, this._commandsConverter, this.handle, resource, ranges, newCommentThreadCommand);
this._commentingRanges.set(commentingRange.handle, commentingRange);
return commentingRange;
}
setActiveCommentingRange(range: vscode.Range) {
this.activeCommentingRange = range;
}
getCommentThread(handle: number) {
return this._threads.get(handle);
}