Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently expand or collapse all comments on a line #176967

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
return this._commentThread;
}

public get expanded(): boolean | undefined {
return this._isExpanded;
}

private _commentOptions: languages.CommentOptions | undefined;

constructor(
Expand Down Expand Up @@ -257,22 +261,12 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
this.commentService.disposeCommentThread(this.owner, this._commentThread.threadId);
}

public collapse(): Promise<void> {
public collapse() {
this._commentThread.collapsibleState = languages.CommentThreadCollapsibleState.Collapsed;
if (this._commentThread.comments && this._commentThread.comments.length === 0) {
this.deleteCommentThread();
return Promise.resolve();
}

this.hide();
return Promise.resolve();
}

public expand(): Promise<void> {
public expand() {
this._commentThread.collapsibleState = languages.CommentThreadCollapsibleState.Expanded;

this.show(this.arrowPosition(this._commentThread.range), 2);
return Promise.resolve();
}

public getGlyphPosition(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ export class CommentController implements IEditorContribution {
// The widget's position is undefined until the widget has been displayed, so rely on the glyph position instead
const existingCommentsAtLine = this._commentWidgets.filter(widget => widget.getGlyphPosition() === commentRange.endLineNumber);
if (existingCommentsAtLine.length) {
existingCommentsAtLine.forEach(widget => widget.toggleExpand());
const allExpanded = existingCommentsAtLine.every(widget => widget.expanded);
existingCommentsAtLine.forEach(allExpanded ? widget => widget.collapse() : widget => widget.expand());
this.processNextThreadToAdd();
return;
} else {
Expand Down