mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 473af338e1bd9ad4d9853933da1cd9d5d9e07dc9 (#5286)
This commit is contained in:
@@ -192,7 +192,7 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
|
||||
|
||||
constructor(
|
||||
public commentThreadHandle: number,
|
||||
public controller: MainThreadCommentController,
|
||||
public controllerHandle: number,
|
||||
public extensionId: string,
|
||||
public threadId: string,
|
||||
public resource: string,
|
||||
@@ -232,7 +232,7 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
|
||||
toJSON(): any {
|
||||
return {
|
||||
$mid: 7,
|
||||
commentControlHandle: this.controller.handle,
|
||||
commentControlHandle: this.controllerHandle,
|
||||
commentThreadHandle: this.commentThreadHandle,
|
||||
};
|
||||
}
|
||||
@@ -290,7 +290,7 @@ export class MainThreadCommentController {
|
||||
): modes.CommentThread2 {
|
||||
let thread = new MainThreadCommentThread(
|
||||
commentThreadHandle,
|
||||
this,
|
||||
this.handle,
|
||||
'',
|
||||
threadId,
|
||||
URI.revive(resource).toString(),
|
||||
@@ -387,15 +387,21 @@ export class MainThreadCommentController {
|
||||
resource: resource, ranges: commentingRanges, newCommentThreadCallback: async (uri: UriComponents, range: IRange) => {
|
||||
let threadHandle = await this._proxy.$createNewCommentWidgetCallback(this.handle, uri, range, token);
|
||||
|
||||
if (threadHandle !== undefined) {
|
||||
return this.getKnownThread(threadHandle);
|
||||
}
|
||||
// if (threadHandle !== undefined) { {{SQL CARBON EDIT}} @anthonydresser this never happens but throws error because of strict null checks
|
||||
// return this.getKnownThread(threadHandle);
|
||||
// }
|
||||
|
||||
return undefined; // {{SQL CARBON EDIT}} @anthonydresser revert back after strict-null-check
|
||||
}
|
||||
} : [],
|
||||
draftMode: modes.DraftMode.NotSupported,
|
||||
template: this._features.commentThreadTemplate
|
||||
template: this._features.commentThreadTemplate ? {
|
||||
controllerHandle: this.handle,
|
||||
label: this._features.commentThreadTemplate.label,
|
||||
acceptInputCommand: this._features.commentThreadTemplate.acceptInputCommand,
|
||||
additionalCommands: this._features.commentThreadTemplate.additionalCommands,
|
||||
deleteCommand: this._features.commentThreadTemplate.deleteCommand
|
||||
} : undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -421,6 +427,28 @@ export class MainThreadCommentController {
|
||||
return ret;
|
||||
}
|
||||
|
||||
getCommentThreadFromTemplate(resource: UriComponents, range: IRange): MainThreadCommentThread {
|
||||
let thread = new MainThreadCommentThread(
|
||||
-1,
|
||||
this.handle,
|
||||
'',
|
||||
'',
|
||||
URI.revive(resource).toString(),
|
||||
range
|
||||
);
|
||||
|
||||
let template = this._features.commentThreadTemplate;
|
||||
|
||||
if (template) {
|
||||
thread.acceptInputCommand = template.acceptInputCommand;
|
||||
thread.additionalCommands = template.additionalCommands;
|
||||
thread.deleteCommand = template.deleteCommand;
|
||||
thread.label = template.label;
|
||||
}
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
return {
|
||||
$mid: 6,
|
||||
@@ -456,7 +484,8 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
this._activeCommentThreadDisposables = [];
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments);
|
||||
this._disposables.push(this._commentService.onDidChangeActiveCommentThread(async thread => {
|
||||
let controller = (thread as MainThreadCommentThread).controller;
|
||||
let handle = (thread as MainThreadCommentThread).controllerHandle;
|
||||
let controller = this._commentControllers.get(handle);
|
||||
|
||||
if (!controller) {
|
||||
return;
|
||||
@@ -468,11 +497,11 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
|
||||
this._activeCommentThreadDisposables.push(this._activeCommentThread.onDidChangeInput(input => { // todo, dispose
|
||||
this._input = input;
|
||||
this._proxy.$onCommentWidgetInputChange(controller.handle, this._input ? this._input.value : undefined);
|
||||
this._proxy.$onCommentWidgetInputChange(handle, URI.parse(this._activeCommentThread!.resource), this._activeCommentThread!.range, this._input ? this._input.value : undefined);
|
||||
}));
|
||||
|
||||
await this._proxy.$onActiveCommentThreadChange(controller.handle, controller.activeCommentThread.commentThreadHandle);
|
||||
await this._proxy.$onCommentWidgetInputChange(controller.handle, this._input ? this._input.value : undefined);
|
||||
await this._proxy.$onCommentWidgetInputChange(controller.handle, URI.parse(this._activeCommentThread!.resource), this._activeCommentThread.range, this._input ? this._input.value : undefined);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -1213,12 +1213,12 @@ export interface ExtHostProgressShape {
|
||||
export interface ExtHostCommentsShape {
|
||||
$provideDocumentComments(handle: number, document: UriComponents): Promise<modes.CommentInfo | null>;
|
||||
$createNewCommentThread(handle: number, document: UriComponents, range: IRange, text: string): Promise<modes.CommentThread | null>;
|
||||
$onCommentWidgetInputChange(commentControllerHandle: number, input: string | undefined): Promise<number | undefined>;
|
||||
$onCommentWidgetInputChange(commentControllerHandle: number, document: UriComponents, range: IRange, input: string | undefined): Promise<number | undefined>;
|
||||
$onActiveCommentThreadChange(commentControllerHandle: number, threadHandle: number | undefined): Promise<number | undefined>;
|
||||
$provideCommentingRanges(commentControllerHandle: number, uriComponents: UriComponents, token: CancellationToken): Promise<IRange[] | undefined>;
|
||||
$provideReactionGroup(commentControllerHandle: number): Promise<modes.CommentReaction[] | undefined>;
|
||||
$toggleReaction(commentControllerHandle: number, threadHandle: number, uri: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void>;
|
||||
$createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): Promise<number | undefined>;
|
||||
$createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): Promise<void>;
|
||||
$replyToCommentThread(handle: number, document: UriComponents, range: IRange, commentThread: modes.CommentThread, text: string): Promise<modes.CommentThread | null>;
|
||||
$editComment(handle: number, document: UriComponents, comment: modes.Comment, text: string): Promise<void>;
|
||||
$deleteComment(handle: number, document: UriComponents, comment: modes.Comment): Promise<void>;
|
||||
|
||||
@@ -88,14 +88,14 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
return commentController;
|
||||
}
|
||||
|
||||
$onCommentWidgetInputChange(commentControllerHandle: number, input: string): Promise<number | undefined> {
|
||||
$onCommentWidgetInputChange(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, input: string): Promise<number | undefined> {
|
||||
const commentController = this._commentControllers.get(commentControllerHandle);
|
||||
|
||||
if (!commentController) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
commentController.$onCommentWidgetInputChange(input);
|
||||
commentController.$onCommentWidgetInputChange(uriComponents, range, input);
|
||||
return Promise.resolve(commentControllerHandle);
|
||||
}
|
||||
|
||||
@@ -157,34 +157,27 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
});
|
||||
}
|
||||
|
||||
$createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): Promise<number | undefined> {
|
||||
$createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): Promise<void> {
|
||||
const commentController = this._commentControllers.get(commentControllerHandle);
|
||||
|
||||
if (!commentController) {
|
||||
return Promise.resolve(undefined);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (!(commentController as any).emptyCommentThreadFactory && !(commentController.commentingRangeProvider && commentController.commentingRangeProvider.createEmptyCommentThread) && !(commentController.emptyCommentThreadFactory && commentController.emptyCommentThreadFactory.createEmptyCommentThread)) {
|
||||
return Promise.resolve(undefined);
|
||||
if (!(commentController as any).emptyCommentThreadFactory && !(commentController.commentingRangeProvider && commentController.commentingRangeProvider.createEmptyCommentThread)) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const document = this._documents.getDocument(URI.revive(uriComponents));
|
||||
return asPromise(() => {
|
||||
if (commentController.emptyCommentThreadFactory) {
|
||||
return commentController.emptyCommentThreadFactory!.createEmptyCommentThread(document, extHostTypeConverter.Range.to(range));
|
||||
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));
|
||||
}
|
||||
|
||||
return undefined; // {{SQL CARBON EDIT}} @anthonydresser revert back after strict-null-check
|
||||
}).then((commentThread: ExtHostCommentThread | undefined) => {
|
||||
if (commentThread) {
|
||||
return Promise.resolve(commentThread.handle);
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
});
|
||||
}).then(() => Promise.resolve());
|
||||
}
|
||||
|
||||
registerWorkspaceCommentProvider(
|
||||
@@ -384,7 +377,11 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
private static _handlePool: number = 0;
|
||||
readonly handle = ExtHostCommentThread._handlePool++;
|
||||
get threadId(): string {
|
||||
return this._threadId;
|
||||
return this._id;
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
get resource(): vscode.Uri {
|
||||
@@ -416,11 +413,11 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
this._onDidUpdateCommentThread.fire();
|
||||
}
|
||||
|
||||
get comments(): vscode.Comment[] {
|
||||
get comments(): (vscode.Comment & vscode.CommentLegacy)[] {
|
||||
return this._comments;
|
||||
}
|
||||
|
||||
set comments(newComments: vscode.Comment[]) {
|
||||
set comments(newComments: (vscode.Comment & vscode.CommentLegacy)[]) {
|
||||
this._comments = newComments;
|
||||
this._onDidUpdateCommentThread.fire();
|
||||
}
|
||||
@@ -478,15 +475,15 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
private _proxy: MainThreadCommentsShape,
|
||||
private readonly _commandsConverter: CommandsConverter,
|
||||
private _commentController: ExtHostCommentController,
|
||||
private _threadId: string,
|
||||
private _id: string,
|
||||
private _resource: vscode.Uri,
|
||||
private _range: vscode.Range,
|
||||
private _comments: vscode.Comment[]
|
||||
private _comments: (vscode.Comment & vscode.CommentLegacy)[]
|
||||
) {
|
||||
this._proxy.$createCommentThread(
|
||||
this._commentController.handle,
|
||||
this.handle,
|
||||
this._threadId,
|
||||
this._id,
|
||||
this._resource,
|
||||
extHostTypeConverter.Range.from(this._range)
|
||||
);
|
||||
@@ -515,7 +512,7 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
this._proxy.$updateCommentThread(
|
||||
this._commentController.handle,
|
||||
this.handle,
|
||||
this._threadId,
|
||||
this._id,
|
||||
this._resource,
|
||||
commentThreadRange,
|
||||
label,
|
||||
@@ -549,12 +546,14 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
}
|
||||
|
||||
export class ExtHostCommentInputBox implements vscode.CommentInputBox {
|
||||
private _onDidChangeValue = new Emitter<string>();
|
||||
|
||||
get onDidChangeValue(): Event<string> {
|
||||
return this._onDidChangeValue.event;
|
||||
get resource(): vscode.Uri {
|
||||
return this._resource;
|
||||
}
|
||||
private _value: string = '';
|
||||
|
||||
get range(): vscode.Range {
|
||||
return this._range;
|
||||
}
|
||||
|
||||
get value(): string {
|
||||
return this._value;
|
||||
}
|
||||
@@ -565,16 +564,24 @@ export class ExtHostCommentInputBox implements vscode.CommentInputBox {
|
||||
this._proxy.$setInputValue(this.commentControllerHandle, newInput);
|
||||
}
|
||||
|
||||
constructor(
|
||||
private _proxy: MainThreadCommentsShape,
|
||||
private _onDidChangeValue = new Emitter<string>();
|
||||
|
||||
public commentControllerHandle: number,
|
||||
input: string
|
||||
) {
|
||||
this._value = input;
|
||||
get onDidChangeValue(): Event<string> {
|
||||
return this._onDidChangeValue.event;
|
||||
}
|
||||
|
||||
setInput(input: string) {
|
||||
constructor(
|
||||
private _proxy: MainThreadCommentsShape,
|
||||
public commentControllerHandle: number,
|
||||
private _resource: vscode.Uri,
|
||||
private _range: vscode.Range,
|
||||
private _value: string
|
||||
) {
|
||||
}
|
||||
|
||||
setInput(resource: vscode.Uri, range: vscode.Range, input: string) {
|
||||
this._resource = resource;
|
||||
this._range = range;
|
||||
this._value = input;
|
||||
}
|
||||
}
|
||||
@@ -607,22 +614,22 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
private _threads: Map<number, ExtHostCommentThread> = new Map<number, ExtHostCommentThread>();
|
||||
commentingRangeProvider?: vscode.CommentingRangeProvider & { createEmptyCommentThread: (document: vscode.TextDocument, range: types.Range) => Promise<vscode.CommentThread>; };
|
||||
|
||||
private _emptyCommentThreadFactory: vscode.EmptyCommentThreadFactory | undefined;
|
||||
get emptyCommentThreadFactory(): vscode.EmptyCommentThreadFactory | undefined {
|
||||
return this._emptyCommentThreadFactory;
|
||||
private _template: vscode.CommentThreadTemplate | undefined;
|
||||
|
||||
get template(): vscode.CommentThreadTemplate | undefined {
|
||||
return this._template;
|
||||
}
|
||||
|
||||
set emptyCommentThreadFactory(newEmptyCommentThreadFactory: vscode.EmptyCommentThreadFactory | undefined) {
|
||||
this._emptyCommentThreadFactory = newEmptyCommentThreadFactory;
|
||||
set template(newTemplate: vscode.CommentThreadTemplate | undefined) {
|
||||
this._template = newTemplate;
|
||||
|
||||
if (this._emptyCommentThreadFactory && this._emptyCommentThreadFactory.template) {
|
||||
let template = this._emptyCommentThreadFactory.template;
|
||||
const acceptInputCommand = template.acceptInputCommand ? this._commandsConverter.toInternal(template.acceptInputCommand) : undefined;
|
||||
const additionalCommands = template.additionalCommands ? template.additionalCommands.map(x => this._commandsConverter.toInternal(x)) : [];
|
||||
const deleteCommand = template.deleteCommand ? this._commandsConverter.toInternal(template.deleteCommand) : undefined;
|
||||
if (newTemplate) {
|
||||
const acceptInputCommand = newTemplate.acceptInputCommand ? this._commandsConverter.toInternal(newTemplate.acceptInputCommand) : undefined;
|
||||
const additionalCommands = newTemplate.additionalCommands ? newTemplate.additionalCommands.map(x => this._commandsConverter.toInternal(x)) : [];
|
||||
const deleteCommand = newTemplate.deleteCommand ? this._commandsConverter.toInternal(newTemplate.deleteCommand) : undefined;
|
||||
this._proxy.$updateCommentControllerFeatures(this.handle, {
|
||||
commentThreadTemplate: {
|
||||
label: template.label,
|
||||
label: newTemplate.label,
|
||||
acceptInputCommand,
|
||||
additionalCommands,
|
||||
deleteCommand
|
||||
@@ -655,17 +662,17 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
this._proxy.$registerCommentController(this.handle, _id, _label);
|
||||
}
|
||||
|
||||
createCommentThread(id: string, resource: vscode.Uri, range: vscode.Range, comments: vscode.Comment[]): vscode.CommentThread {
|
||||
createCommentThread(id: string, resource: vscode.Uri, range: vscode.Range, comments: (vscode.Comment & vscode.CommentLegacy)[]): vscode.CommentThread {
|
||||
const commentThread = new ExtHostCommentThread(this._proxy, this._commandsConverter, this, id, resource, range, comments);
|
||||
this._threads.set(commentThread.handle, commentThread);
|
||||
return commentThread;
|
||||
}
|
||||
|
||||
$onCommentWidgetInputChange(input: string) {
|
||||
$onCommentWidgetInputChange(uriComponents: UriComponents, range: IRange, input: string) {
|
||||
if (!this.inputBox) {
|
||||
this.inputBox = new ExtHostCommentInputBox(this._proxy, this.handle, input);
|
||||
this.inputBox = new ExtHostCommentInputBox(this._proxy, this.handle, URI.revive(uriComponents), extHostTypeConverter.Range.to(range), input);
|
||||
} else {
|
||||
this.inputBox.setInput(input);
|
||||
this.inputBox.setInput(URI.revive(uriComponents), extHostTypeConverter.Range.to(range), input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,25 +705,27 @@ function convertCommentInfo(owner: number, extensionId: ExtensionIdentifier, pro
|
||||
function convertToCommentThread(extensionId: ExtensionIdentifier, provider: vscode.DocumentCommentProvider | vscode.WorkspaceCommentProvider, vscodeCommentThread: vscode.CommentThread, commandsConverter: CommandsConverter): modes.CommentThread {
|
||||
return {
|
||||
extensionId: extensionId.value,
|
||||
threadId: vscodeCommentThread.threadId,
|
||||
threadId: vscodeCommentThread.id,
|
||||
resource: vscodeCommentThread.resource.toString(),
|
||||
range: extHostTypeConverter.Range.from(vscodeCommentThread.range),
|
||||
comments: vscodeCommentThread.comments.map(comment => convertToComment(provider, comment, commandsConverter)),
|
||||
comments: vscodeCommentThread.comments.map(comment => convertToComment(provider, comment as vscode.Comment & vscode.CommentLegacy, commandsConverter)),
|
||||
collapsibleState: vscodeCommentThread.collapsibleState
|
||||
};
|
||||
}
|
||||
|
||||
function convertFromCommentThread(commentThread: modes.CommentThread): vscode.CommentThread {
|
||||
return {
|
||||
id: commentThread.threadId!,
|
||||
threadId: commentThread.threadId!,
|
||||
resource: URI.parse(commentThread.resource!),
|
||||
range: extHostTypeConverter.Range.to(commentThread.range),
|
||||
comments: commentThread.comments ? commentThread.comments.map(convertFromComment) : [],
|
||||
collapsibleState: commentThread.collapsibleState
|
||||
};
|
||||
collapsibleState: commentThread.collapsibleState,
|
||||
dispose: () => { }
|
||||
} as vscode.CommentThread;
|
||||
}
|
||||
|
||||
function convertFromComment(comment: modes.Comment): vscode.Comment {
|
||||
function convertFromComment(comment: modes.Comment): vscode.Comment & vscode.CommentLegacy {
|
||||
let userIconPath: URI | undefined;
|
||||
if (comment.userIconPath) {
|
||||
try {
|
||||
@@ -745,7 +754,7 @@ function convertFromComment(comment: modes.Comment): vscode.Comment {
|
||||
};
|
||||
}
|
||||
|
||||
function convertToModeComment(commentController: ExtHostCommentController, vscodeComment: vscode.Comment, commandsConverter: CommandsConverter): modes.Comment {
|
||||
function convertToModeComment(commentController: ExtHostCommentController, vscodeComment: vscode.Comment & vscode.CommentLegacy, commandsConverter: CommandsConverter): modes.Comment {
|
||||
const iconPath = vscodeComment.userIconPath ? vscodeComment.userIconPath.toString() : vscodeComment.gravatar;
|
||||
|
||||
return {
|
||||
@@ -762,7 +771,7 @@ function convertToModeComment(commentController: ExtHostCommentController, vscod
|
||||
};
|
||||
}
|
||||
|
||||
function convertToComment(provider: vscode.DocumentCommentProvider | vscode.WorkspaceCommentProvider, vscodeComment: vscode.Comment, commandsConverter: CommandsConverter): modes.Comment {
|
||||
function convertToComment(provider: vscode.DocumentCommentProvider | vscode.WorkspaceCommentProvider, vscodeComment: vscode.Comment & vscode.CommentLegacy, commandsConverter: CommandsConverter): modes.Comment {
|
||||
const canEdit = !!(provider as vscode.DocumentCommentProvider).editComment && vscodeComment.canEdit;
|
||||
const canDelete = !!(provider as vscode.DocumentCommentProvider).deleteComment && vscodeComment.canDelete;
|
||||
const iconPath = vscodeComment.userIconPath ? vscodeComment.userIconPath.toString() : vscodeComment.gravatar;
|
||||
|
||||
@@ -781,6 +781,7 @@ export function createApiFactory(
|
||||
ColorInformation: extHostTypes.ColorInformation,
|
||||
ColorPresentation: extHostTypes.ColorPresentation,
|
||||
Comment: extHostTypes.Comment,
|
||||
CommentLegacy: extHostTypes.Comment,
|
||||
CommentThreadCollapsibleState: extHostTypes.CommentThreadCollapsibleState,
|
||||
CompletionItem: extHostTypes.CompletionItem,
|
||||
CompletionItemKind: extHostTypes.CompletionItemKind,
|
||||
|
||||
@@ -66,6 +66,7 @@ export interface ICommentService {
|
||||
deleteReaction(owner: string, resource: URI, comment: Comment, reaction: CommentReaction): Promise<void>;
|
||||
getReactionGroup(owner: string): CommentReaction[] | undefined;
|
||||
toggleReaction(owner: string, resource: URI, thread: CommentThread2, comment: Comment, reaction: CommentReaction): Promise<void>;
|
||||
getCommentThreadFromTemplate(owner: string, resource: URI, range: IRange, ): CommentThread2 | undefined;
|
||||
setActiveCommentThread(commentThread: CommentThread | null): void;
|
||||
setInput(input: string): void;
|
||||
}
|
||||
@@ -255,6 +256,16 @@ export class CommentService extends Disposable implements ICommentService {
|
||||
}
|
||||
}
|
||||
|
||||
getCommentThreadFromTemplate(owner: string, resource: URI, range: IRange, ): CommentThread2 | undefined {
|
||||
const commentController = this._commentControls.get(owner);
|
||||
|
||||
if (commentController) {
|
||||
return commentController.getCommentThreadFromTemplate(resource, range);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getReactionGroup(owner: string): CommentReaction[] | undefined {
|
||||
const commentProvider = this._commentControls.get(owner);
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
private _commentGlyph?: CommentGlyphWidget;
|
||||
private _submitActionsDisposables: IDisposable[];
|
||||
private _globalToDispose: IDisposable[];
|
||||
private _commentThreadDisposables: IDisposable[] = [];
|
||||
private _markdownRenderer: MarkdownRenderer;
|
||||
private _styleElement: HTMLStyleElement;
|
||||
private _formActions: HTMLElement | null;
|
||||
@@ -103,6 +104,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
this._resizeObserver = null;
|
||||
this._isExpanded = _commentThread.collapsibleState ? _commentThread.collapsibleState === modes.CommentThreadCollapsibleState.Expanded : undefined;
|
||||
this._globalToDispose = [];
|
||||
this._commentThreadDisposables = [];
|
||||
this._submitActionsDisposables = [];
|
||||
this._formActions = null;
|
||||
this.create();
|
||||
@@ -214,6 +216,9 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
if (deleteCommand) {
|
||||
this.commentService.setActiveCommentThread(this._commentThread);
|
||||
return this.commandService.executeCommand(deleteCommand.id, ...(deleteCommand.arguments || []));
|
||||
} else if (this._commentEditor.getValue() === '') {
|
||||
this.dispose();
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,6 +296,12 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
this._commentElements = newCommentNodeList;
|
||||
this.createThreadLabel(replaceTemplate);
|
||||
|
||||
if (replaceTemplate) {
|
||||
// since we are replacing the old comment thread, we need to rebind the listeners.
|
||||
this._commentThreadDisposables.forEach(global => global.dispose());
|
||||
this._commentThreadDisposables = [];
|
||||
}
|
||||
|
||||
if (replaceTemplate) {
|
||||
this.createTextModelListener();
|
||||
}
|
||||
@@ -395,7 +406,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
this._commentEditor.setModel(model);
|
||||
this._disposables.push(this._commentEditor);
|
||||
this._disposables.push(this._commentEditor.getModel()!.onDidChangeContent(() => this.setCommentEditorDecorations()));
|
||||
if ((this._commentThread as modes.CommentThread2).commentThreadHandle !== undefined && !fromTemplate) {
|
||||
if ((this._commentThread as modes.CommentThread2).commentThreadHandle !== undefined) {
|
||||
this.createTextModelListener();
|
||||
}
|
||||
|
||||
@@ -445,7 +456,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
}
|
||||
|
||||
private createTextModelListener() {
|
||||
this._disposables.push(this._commentEditor.onDidFocusEditorWidget(() => {
|
||||
this._commentThreadDisposables.push(this._commentEditor.onDidFocusEditorWidget(() => {
|
||||
let commentThread = this._commentThread as modes.CommentThread2;
|
||||
commentThread.input = {
|
||||
uri: this._commentEditor.getModel()!.uri,
|
||||
@@ -454,7 +465,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
this.commentService.setActiveCommentThread(this._commentThread);
|
||||
}));
|
||||
|
||||
this._disposables.push(this._commentEditor.getModel()!.onDidChangeContent(() => {
|
||||
this._commentThreadDisposables.push(this._commentEditor.getModel()!.onDidChangeContent(() => {
|
||||
let modelContent = this._commentEditor.getValue();
|
||||
let thread = (this._commentThread as modes.CommentThread2);
|
||||
if (thread.input && thread.input.uri === this._commentEditor.getModel()!.uri && thread.input.value !== modelContent) {
|
||||
@@ -464,7 +475,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
}
|
||||
}));
|
||||
|
||||
this._disposables.push((this._commentThread as modes.CommentThread2).onDidChangeInput(input => {
|
||||
this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeInput(input => {
|
||||
let thread = (this._commentThread as modes.CommentThread2);
|
||||
|
||||
if (thread.input && thread.input.uri !== this._commentEditor.getModel()!.uri) {
|
||||
@@ -489,31 +500,31 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
}
|
||||
}));
|
||||
|
||||
this._disposables.push((this._commentThread as modes.CommentThread2).onDidChangeComments(async _ => {
|
||||
this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeComments(async _ => {
|
||||
await this.update(this._commentThread);
|
||||
}));
|
||||
|
||||
this._disposables.push((this._commentThread as modes.CommentThread2).onDidChangeLabel(_ => {
|
||||
this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeLabel(_ => {
|
||||
this.createThreadLabel();
|
||||
}));
|
||||
}
|
||||
|
||||
private createCommentWidgetActionsListener(container: HTMLElement, model: ITextModel) {
|
||||
this._disposables.push((this._commentThread as modes.CommentThread2).onDidChangeAcceptInputCommand(_ => {
|
||||
this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeAcceptInputCommand(_ => {
|
||||
if (container) {
|
||||
dom.clearNode(container);
|
||||
this.createCommentWidgetActions2(container, model);
|
||||
}
|
||||
}));
|
||||
|
||||
this._disposables.push((this._commentThread as modes.CommentThread2).onDidChangeAdditionalCommands(_ => {
|
||||
this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeAdditionalCommands(_ => {
|
||||
if (container) {
|
||||
dom.clearNode(container);
|
||||
this.createCommentWidgetActions2(container, model);
|
||||
}
|
||||
}));
|
||||
|
||||
this._disposables.push((this._commentThread as modes.CommentThread2).onDidChangeRange(range => {
|
||||
this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeRange(range => {
|
||||
// Move comment glyph widget and show position if the line has changed.
|
||||
const lineNumber = this._commentThread.range.startLineNumber;
|
||||
let shouldMoveWidget = false;
|
||||
@@ -529,7 +540,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
}
|
||||
}));
|
||||
|
||||
this._disposables.push((this._commentThread as modes.CommentThread2).onDidChangeCollasibleState(state => {
|
||||
this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeCollasibleState(state => {
|
||||
if (state === modes.CommentThreadCollapsibleState.Expanded && !this._isExpanded) {
|
||||
const lineNumber = this._commentThread.range.startLineNumber;
|
||||
|
||||
@@ -1062,6 +1073,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
}
|
||||
|
||||
this._globalToDispose.forEach(global => global.dispose());
|
||||
this._commentThreadDisposables.forEach(global => global.dispose());
|
||||
this._submitActionsDisposables.forEach(local => local.dispose());
|
||||
this._onDidClose.fire(undefined);
|
||||
}
|
||||
|
||||
@@ -446,6 +446,13 @@ export class ReviewController implements IEditorContribution {
|
||||
return;
|
||||
}
|
||||
|
||||
let matchedNewCommentThreadZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && (zoneWidget.commentThread as any).commentThreadHandle === -1 && Range.equalsRange(zoneWidget.commentThread.range, thread.range));
|
||||
|
||||
if (matchedNewCommentThreadZones.length) {
|
||||
matchedNewCommentThreadZones[0].update(thread, true);
|
||||
return;
|
||||
}
|
||||
|
||||
const pendingCommentText = this._pendingCommentCache[e.owner] && this._pendingCommentCache[e.owner][thread.threadId];
|
||||
this.displayCommentThread(e.owner, thread, pendingCommentText, draftMode);
|
||||
this._commentInfos.filter(info => info.owner === e.owner)[0].threads.push(thread);
|
||||
@@ -462,26 +469,18 @@ export class ReviewController implements IEditorContribution {
|
||||
this._commentWidgets.push(zoneWidget);
|
||||
}
|
||||
|
||||
private addCommentThreadFromTemplate(lineNumber: number, ownerId: string, extensionId: string | undefined, template: modes.CommentThreadTemplate): ReviewZoneWidget {
|
||||
let templateReviewZoneWidget = this.instantiationService.createInstance(ReviewZoneWidget, this.editor, ownerId, {
|
||||
commentThreadHandle: -1,
|
||||
label: template!.label,
|
||||
acceptInputCommand: template.acceptInputCommand,
|
||||
additionalCommands: template.additionalCommands,
|
||||
deleteCommand: template.deleteCommand,
|
||||
extensionId: extensionId,
|
||||
threadId: null,
|
||||
resource: null,
|
||||
comments: [],
|
||||
range: {
|
||||
startLineNumber: lineNumber,
|
||||
startColumn: 0,
|
||||
endLineNumber: lineNumber,
|
||||
endColumn: 0
|
||||
},
|
||||
collapsibleState: modes.CommentThreadCollapsibleState.Expanded,
|
||||
},
|
||||
'', modes.DraftMode.NotSupported);
|
||||
private addCommentThreadFromTemplate(lineNumber: number, ownerId: string): ReviewZoneWidget {
|
||||
let templateCommentThread = this.commentService.getCommentThreadFromTemplate(ownerId, this.editor.getModel()!.uri, {
|
||||
startLineNumber: lineNumber,
|
||||
startColumn: 1,
|
||||
endLineNumber: lineNumber,
|
||||
endColumn: 1
|
||||
})!;
|
||||
|
||||
templateCommentThread.collapsibleState = modes.CommentThreadCollapsibleState.Expanded;
|
||||
templateCommentThread.comments = [];
|
||||
|
||||
let templateReviewZoneWidget = this.instantiationService.createInstance(ReviewZoneWidget, this.editor, ownerId, templateCommentThread, '', modes.DraftMode.NotSupported);
|
||||
|
||||
return templateReviewZoneWidget;
|
||||
}
|
||||
@@ -692,22 +691,19 @@ export class ReviewController implements IEditorContribution {
|
||||
public addCommentAtLine2(lineNumber: number, replyCommand: modes.Command | undefined, ownerId: string, extensionId: string | undefined, commentingRangesInfo: modes.CommentingRanges | undefined, template: modes.CommentThreadTemplate | undefined) {
|
||||
if (commentingRangesInfo) {
|
||||
let range = new Range(lineNumber, 1, lineNumber, 1);
|
||||
if (commentingRangesInfo.newCommentThreadCallback && template) {
|
||||
if (template) {
|
||||
// create comment widget through template
|
||||
let commentThreadWidget = this.addCommentThreadFromTemplate(lineNumber, ownerId, extensionId, template);
|
||||
let commentThreadWidget = this.addCommentThreadFromTemplate(lineNumber, ownerId);
|
||||
commentThreadWidget.display(lineNumber, true);
|
||||
|
||||
return commentingRangesInfo.newCommentThreadCallback(this.editor.getModel()!.uri, range)
|
||||
.then(commentThread => {
|
||||
commentThreadWidget.update(commentThread!, true);
|
||||
this._commentWidgets.push(commentThreadWidget);
|
||||
this.processNextThreadToAdd();
|
||||
})
|
||||
.catch(e => {
|
||||
this.notificationService.error(nls.localize('commentThreadAddFailure', "Adding a new comment thread failed: {0}.", e.message));
|
||||
commentThreadWidget.dispose();
|
||||
this.processNextThreadToAdd();
|
||||
});
|
||||
this._commentWidgets.push(commentThreadWidget);
|
||||
commentThreadWidget.onDidClose(() => {
|
||||
this._commentWidgets = this._commentWidgets.filter(zoneWidget => !(
|
||||
zoneWidget.owner === commentThreadWidget.owner &&
|
||||
(zoneWidget.commentThread as any).commentThreadHandle === -1 &&
|
||||
Range.equalsRange(zoneWidget.commentThread.range, commentThreadWidget.commentThread.range)
|
||||
));
|
||||
});
|
||||
this.processNextThreadToAdd();
|
||||
} else if (commentingRangesInfo.newCommentThreadCallback) {
|
||||
return commentingRangesInfo.newCommentThreadCallback(this.editor.getModel()!.uri, range)
|
||||
.then(_ => {
|
||||
|
||||
@@ -168,7 +168,7 @@ export class TooltipWidget extends ExtensionWidget {
|
||||
this.parent.removeAttribute('aria-label');
|
||||
this.parent.title = this.getTooltip();
|
||||
if (this.extension) {
|
||||
this.parent.setAttribute('aria-label', localize('extension-arialabel', "{0}. {1} Press enter for extension details.", this.extension.displayName));
|
||||
this.parent.setAttribute('aria-label', localize('extension-arialabel', "{0}. Press enter for extension details.", this.extension.displayName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user