Comments widget doesn't reveal nicely (#148897)

Fixes #148774
This commit is contained in:
Alex Ross
2022-05-06 15:18:01 +02:00
committed by GitHub
parent f49cccd02d
commit 02b59c6e3a
6 changed files with 40 additions and 11 deletions

View File

@@ -122,13 +122,14 @@ export type CommentThreadChanges<T = IRange> = Partial<{
collapseState: languages.CommentThreadCollapsibleState;
canReply: boolean;
state: languages.CommentThreadState;
isTemplate: boolean;
}>;
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 | ICellRange, extensionId: ExtensionIdentifier): languages.CommentThread<IRange | ICellRange> | undefined;
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange | ICellRange, extensionId: ExtensionIdentifier, isTemplate: boolean): languages.CommentThread<IRange | ICellRange> | undefined;
$updateCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, changes: CommentThreadChanges): void;
$deleteCommentThread(handle: number, commentThreadHandle: number): void;
$updateCommentingRanges(handle: number): void;

View File

@@ -224,6 +224,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
collapsibleState: vscode.CommentThreadCollapsibleState;
canReply: boolean;
state: vscode.CommentThreadState;
isTemplate: boolean;
}>;
class ExtHostCommentThread implements vscode.CommentThread {
@@ -362,7 +363,8 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
private _uri: vscode.Uri,
private _range: vscode.Range,
private _comments: vscode.Comment[],
public readonly extensionDescription: IExtensionDescription
public readonly extensionDescription: IExtensionDescription,
private _isTemplate: boolean
) {
this._acceptInputDisposables.value = new DisposableStore();
@@ -376,7 +378,8 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
this._id,
this._uri,
extHostTypeConverter.Range.from(this._range),
extensionDescription.identifier
extensionDescription.identifier,
this._isTemplate
);
this._localDisposables = [];
@@ -421,12 +424,19 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
};
}
private updateIsTemplate() {
if (this._isTemplate) {
this._isTemplate = false;
this.modifications.isTemplate = false;
}
}
@debounce(100)
eventuallyUpdateCommentThread(): void {
if (this._isDiposed) {
return;
}
this.updateIsTemplate();
if (!this._acceptInputDisposables.value) {
this._acceptInputDisposables.value = new DisposableStore();
@@ -462,6 +472,9 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
if (modified('state')) {
formattedModifications.state = convertToState(this._state);
}
if (modified('isTemplate')) {
formattedModifications.isTemplate = this._isTemplate;
}
this.modifications = {};
proxy.$updateCommentThread(
@@ -582,18 +595,18 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
createCommentThread(resource: vscode.Uri, range: vscode.Range, comments: vscode.Comment[]): ExtHostCommentThread;
createCommentThread(arg0: vscode.Uri | string, arg1: vscode.Uri | vscode.Range, arg2: vscode.Range | vscode.Comment[], arg3?: vscode.Comment[]): vscode.CommentThread {
if (typeof arg0 === 'string') {
const commentThread = new ExtHostCommentThread(this.id, this.handle, arg0, arg1 as vscode.Uri, arg2 as vscode.Range, arg3 as vscode.Comment[], this._extension);
const commentThread = new ExtHostCommentThread(this.id, this.handle, arg0, arg1 as vscode.Uri, arg2 as vscode.Range, arg3 as vscode.Comment[], this._extension, false);
this._threads.set(commentThread.handle, commentThread);
return commentThread;
} else {
const commentThread = new ExtHostCommentThread(this.id, this.handle, undefined, arg0 as vscode.Uri, arg1 as vscode.Range, arg2 as vscode.Comment[], this._extension);
const commentThread = new ExtHostCommentThread(this.id, this.handle, undefined, arg0 as vscode.Uri, arg1 as vscode.Range, arg2 as vscode.Comment[], this._extension, false);
this._threads.set(commentThread.handle, commentThread);
return commentThread;
}
}
$createCommentThreadTemplate(uriComponents: UriComponents, range: IRange): ExtHostCommentThread {
const commentThread = new ExtHostCommentThread(this.id, this.handle, undefined, URI.revive(uriComponents), extHostTypeConverter.Range.to(range), [], this._extension);
const commentThread = new ExtHostCommentThread(this.id, this.handle, undefined, URI.revive(uriComponents), extHostTypeConverter.Range.to(range), [], this._extension, true);
commentThread.collapsibleState = languages.CommentThreadCollapsibleState.Expanded;
this._threads.set(commentThread.handle, commentThread);
return commentThread;