Skip to content

Commit

Permalink
Allow specific comments to be focused on (microsoft#228770)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 authored Sep 16, 2024
1 parent a9d2b65 commit dc8e741
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ export class CommentThreadBody<T extends IRange | ICellRange = IRange> extends D
this._markdownRenderer = this._register(new MarkdownRenderer(this._options, this.languageService, this.openerService));
}

focus() {
focus(commentUniqueId?: number) {
if (commentUniqueId !== undefined) {
const comment = this._commentElements.find(commentNode => commentNode.comment.uniqueIdInThread === commentUniqueId);
if (comment) {
comment.focus();
return;
}
}
this._commentsElement.focus();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ export class CommentThreadWidget<T extends IRange | ICellRange = IRange> extends
this._commentReply?.expandReplyAreaAndFocusCommentEditor();
}

focus() {
this._body.focus();
focus(commentUniqueId: number | undefined) {
this._body.focus(commentUniqueId);
}

async submitComment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
}
}

private _setFocus(focus: CommentWidgetFocus) {
private _setFocus(commentUniqueId: number | undefined, focus: CommentWidgetFocus) {
if (focus === CommentWidgetFocus.Widget) {
this._commentThreadWidget.focus();
this._commentThreadWidget.focus(commentUniqueId);
} else if (focus === CommentWidgetFocus.Editor) {
this._commentThreadWidget.focusCommentEditor();
}
Expand All @@ -217,7 +217,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
scrollTop = this.editor.getTopForLineNumber(this._commentThread.range.startLineNumber) - height / 2 + commentCoords.top - commentThreadCoords.top;
}
this.editor.setScrollTop(scrollTop);
this._setFocus(focus);
this._setFocus(commentUniqueId, focus);
} else {
this._goToThread(focus);
}
Expand All @@ -229,7 +229,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
: new Range(1, 1, 1, 1);

this.editor.revealRangeInCenter(rangeToReveal);
this._setFocus(focus);
this._setFocus(undefined, focus);
}

public makeVisible(commentUniqueId?: number, focus: CommentWidgetFocus = CommentWidgetFocus.None) {
Expand Down

0 comments on commit dc8e741

Please sign in to comment.