Skip to content

Commit

Permalink
Fix comment threads starting expanded (#218684)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 authored Jun 27, 2024
1 parent 5ba8a8b commit 53ed076
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/vs/workbench/api/browser/mainThreadComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,16 @@ export class MainThreadCommentThread<T> implements languages.CommentThread<T> {
public threadId: string,
public resource: string,
private _range: T | undefined,
comments: languages.Comment[] | undefined,
private _canReply: boolean,
private _isTemplate: boolean,
public editorId?: string
) {
this._isDisposed = false;
if (_isTemplate) {
this.comments = [];
} else if (comments) {
this._comments = comments;
}
}

Expand Down Expand Up @@ -298,6 +301,7 @@ export class MainThreadCommentController implements ICommentController {
threadId: string,
resource: UriComponents,
range: IRange | ICellRange | undefined,
comments: languages.Comment[],
isTemplate: boolean,
editorId?: string
): languages.CommentThread<IRange | ICellRange> {
Expand All @@ -308,6 +312,7 @@ export class MainThreadCommentController implements ICommentController {
threadId,
URI.revive(resource).toString(),
range,
comments,
true,
isTemplate,
editorId
Expand Down Expand Up @@ -590,6 +595,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
threadId: string,
resource: UriComponents,
range: IRange | ICellRange | undefined,
comments: languages.Comment[],
extensionId: ExtensionIdentifier,
isTemplate: boolean,
editorId?: string
Expand All @@ -600,7 +606,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
return undefined;
}

return provider.createCommentThread(extensionId.value, commentThreadHandle, threadId, resource, range, isTemplate, editorId);
return provider.createCommentThread(extensionId.value, commentThreadHandle, threadId, resource, range, comments, isTemplate, editorId);
}

$updateCommentThread(handle: number,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export interface MainThreadCommentsShape extends IDisposable {
$registerCommentController(handle: number, id: string, label: string, extensionId: string): void;
$unregisterCommentController(handle: number): void;
$updateCommentControllerFeatures(handle: number, features: CommentProviderFeatures): void;
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange | ICellRange | undefined, extensionId: ExtensionIdentifier, isTemplate: boolean, editorId?: string): languages.CommentThread<IRange | ICellRange> | undefined;
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange | ICellRange | undefined, comments: languages.Comment[], extensionId: ExtensionIdentifier, isTemplate: boolean, editorId?: string): 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, resourceHints?: languages.CommentingRangeResourceHint): void;
Expand Down
4 changes: 1 addition & 3 deletions src/vs/workbench/api/common/extHostComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
this._id,
this._uri,
extHostTypeConverter.Range.from(this._range),
this._comments.map(cmt => convertToDTOComment(this, cmt, this._commentsMap, this.extensionDescription)),
extensionDescription.identifier,
this._isTemplate,
editorId
Expand All @@ -436,9 +437,6 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
this.eventuallyUpdateCommentThread();
}));

// set up comments after ctor to batch update events.
this.comments = _comments;

this._localDisposables.push({
dispose: () => {
proxy.$deleteCommentThread(
Expand Down

0 comments on commit 53ed076

Please sign in to comment.