mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 01:25:36 -05:00
Merge from vscode 5b9869eb02fa4c96205a74d05cad9164dfd06d60 (#5607)
This commit is contained in:
@@ -106,6 +106,16 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
|
||||
this._onDidChangeLabel.fire(this._label);
|
||||
}
|
||||
|
||||
private _contextValue: string | undefined;
|
||||
|
||||
get contextValue(): string | undefined {
|
||||
return this._contextValue;
|
||||
}
|
||||
|
||||
set contextValue(context: string | undefined) {
|
||||
this._contextValue = context;
|
||||
}
|
||||
|
||||
private _onDidChangeLabel = new Emitter<string>();
|
||||
get onDidChangeLabel(): Event<string> { return this._onDidChangeLabel.event; }
|
||||
|
||||
@@ -204,6 +214,7 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
|
||||
batchUpdate(
|
||||
range: IRange,
|
||||
label: string,
|
||||
contextValue: string | undefined,
|
||||
comments: modes.Comment[],
|
||||
acceptInputCommand: modes.Command | undefined,
|
||||
additionalCommands: modes.Command[],
|
||||
@@ -211,6 +222,7 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
|
||||
collapsibleState: modes.CommentThreadCollapsibleState) {
|
||||
this._range = range;
|
||||
this._label = label;
|
||||
this._contextValue = contextValue;
|
||||
this._comments = comments;
|
||||
this._acceptInputCommand = acceptInputCommand;
|
||||
this._additionalCommands = additionalCommands;
|
||||
@@ -247,6 +259,10 @@ export class MainThreadCommentController {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
get contextValue(): string {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
get proxy(): ExtHostCommentsShape {
|
||||
return this._proxy;
|
||||
}
|
||||
@@ -319,13 +335,14 @@ export class MainThreadCommentController {
|
||||
resource: UriComponents,
|
||||
range: IRange,
|
||||
label: string,
|
||||
contextValue: string | undefined,
|
||||
comments: modes.Comment[],
|
||||
acceptInputCommand: modes.Command | undefined,
|
||||
additionalCommands: modes.Command[],
|
||||
deleteCommand: modes.Command | undefined,
|
||||
collapsibleState: modes.CommentThreadCollapsibleState): void {
|
||||
let thread = this.getKnownThread(commentThreadHandle);
|
||||
thread.batchUpdate(range, label, comments, acceptInputCommand, additionalCommands, deleteCommand, collapsibleState);
|
||||
thread.batchUpdate(range, label, contextValue, comments, acceptInputCommand, additionalCommands, deleteCommand, collapsibleState);
|
||||
|
||||
this._commentService.updateComments(this._uniqueId, {
|
||||
added: [],
|
||||
@@ -349,6 +366,14 @@ export class MainThreadCommentController {
|
||||
thread.dispose();
|
||||
}
|
||||
|
||||
deleteCommentThreadMain(commentThreadId: string) {
|
||||
this._threads.forEach(thread => {
|
||||
if (thread.threadId === commentThreadId) {
|
||||
this._proxy.$deleteCommentThread(this._handle, thread.commentThreadHandle);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateInput(input: string) {
|
||||
let thread = this.activeCommentThread;
|
||||
|
||||
@@ -377,31 +402,26 @@ export class MainThreadCommentController {
|
||||
}
|
||||
|
||||
let commentingRanges = await this._proxy.$provideCommentingRanges(this.handle, resource, token);
|
||||
let staticContribution = await this._proxy.$checkStaticContribution(this.handle);
|
||||
|
||||
return <ICommentInfo>{
|
||||
owner: this._uniqueId,
|
||||
label: this.label,
|
||||
threads: ret,
|
||||
commentingRanges: commentingRanges ?
|
||||
{
|
||||
resource: resource, ranges: commentingRanges, newCommentThreadCallback: async (uri: UriComponents, range: IRange) => {
|
||||
let threadHandle = await this._proxy.$createNewCommentWidgetCallback(this.handle, uri, range, token);
|
||||
commentingRanges: commentingRanges ? {
|
||||
resource: resource,
|
||||
ranges: commentingRanges,
|
||||
newCommentThreadCallback: staticContribution ? undefined : async (uri: UriComponents, range: IRange) => {
|
||||
let threadHandle = await this._proxy.$createNewCommentWidgetCallback(this.handle, uri, range, token);
|
||||
|
||||
// if (threadHandle !== undefined) { {{SQL CARBON EDIT}} @anthonydresser this never happens but throws error because of strict null checks
|
||||
// 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 ? {
|
||||
controllerHandle: this.handle,
|
||||
label: this._features.commentThreadTemplate.label,
|
||||
acceptInputCommand: this._features.commentThreadTemplate.acceptInputCommand,
|
||||
additionalCommands: this._features.commentThreadTemplate.additionalCommands,
|
||||
deleteCommand: this._features.commentThreadTemplate.deleteCommand
|
||||
} : undefined
|
||||
return undefined; // {{SQL CARBON EDIT}} @anthonydresser revert back after strict-null-check
|
||||
}
|
||||
} : [],
|
||||
draftMode: modes.DraftMode.NotSupported
|
||||
};
|
||||
}
|
||||
|
||||
@@ -427,26 +447,8 @@ 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;
|
||||
createCommentThreadTemplate(resource: UriComponents, range: IRange): void {
|
||||
this._proxy.$createCommentThreadTemplate(this.handle, resource, range);
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
@@ -467,8 +469,6 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
private _handlers = new Map<number, string>();
|
||||
private _commentControllers = new Map<number, MainThreadCommentController>();
|
||||
|
||||
private _activeCommentThread?: MainThreadCommentThread;
|
||||
private _input?: modes.CommentInput;
|
||||
private _openPanelListener: IDisposable | null;
|
||||
|
||||
constructor(
|
||||
@@ -477,32 +477,12 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
@ICommentService private readonly _commentService: ICommentService,
|
||||
@IPanelService private readonly _panelService: IPanelService,
|
||||
@ITelemetryService private readonly _telemetryService: ITelemetryService,
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
) {
|
||||
super();
|
||||
this._disposables = [];
|
||||
this._activeCommentThreadDisposables = [];
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments);
|
||||
this._disposables.push(this._commentService.onDidChangeActiveCommentThread(async thread => {
|
||||
let handle = (thread as MainThreadCommentThread).controllerHandle;
|
||||
let controller = this._commentControllers.get(handle);
|
||||
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._activeCommentThreadDisposables = dispose(this._activeCommentThreadDisposables);
|
||||
this._activeCommentThread = thread as MainThreadCommentThread;
|
||||
controller.activeCommentThread = this._activeCommentThread;
|
||||
|
||||
this._activeCommentThreadDisposables.push(this._activeCommentThread.onDidChangeInput(input => { // todo, dispose
|
||||
this._input = input;
|
||||
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, URI.parse(this._activeCommentThread!.resource), this._activeCommentThread.range, this._input ? this._input.value : undefined);
|
||||
}));
|
||||
}
|
||||
|
||||
$registerCommentController(handle: number, id: string, label: string): void {
|
||||
@@ -562,6 +542,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
resource: UriComponents,
|
||||
range: IRange,
|
||||
label: string,
|
||||
contextValue: string | undefined,
|
||||
comments: modes.Comment[],
|
||||
acceptInputCommand: modes.Command | undefined,
|
||||
additionalCommands: modes.Command[],
|
||||
@@ -573,7 +554,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return provider.updateCommentThread(commentThreadHandle, threadId, resource, range, label, comments, acceptInputCommand, additionalCommands, deleteCommand, collapsibleState);
|
||||
return provider.updateCommentThread(commentThreadHandle, threadId, resource, range, label, contextValue, comments, acceptInputCommand, additionalCommands, deleteCommand, collapsibleState);
|
||||
}
|
||||
|
||||
$deleteCommentThread(handle: number, commentThreadHandle: number) {
|
||||
|
||||
Reference in New Issue
Block a user