diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadBody.ts b/src/vs/workbench/contrib/comments/browser/commentThreadBody.ts index 739cf5c0de7..320c693c32a 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadBody.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadBody.ts @@ -156,7 +156,7 @@ export class CommentThreadBody extends D return; } - updateCommentThread(commentThread: languages.CommentThread) { + updateCommentThread(commentThread: languages.CommentThread, preserveFocus: boolean) { const oldCommentsLen = this._commentElements.length; const newCommentsLen = commentThread.comments ? commentThread.comments.length : 0; @@ -222,7 +222,9 @@ export class CommentThreadBody extends D } this._updateAriaLabel(); - this._setFocusedComment(this._focusedComment); + if (!preserveFocus) { + this._setFocusedComment(this._focusedComment); + } } private _updateAriaLabel() { diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index 7e8ad06e90a..a234e880a0e 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -213,7 +213,7 @@ export class CommentThreadWidget extends this._commentThreadDisposables = []; this._bindCommentThreadListeners(); - this._body.updateCommentThread(commentThread); + this._body.updateCommentThread(commentThread, this._commentReply?.isCommentEditorFocused() ?? false); this._threadIsEmpty.set(!this._body.length); this._header.updateCommentThread(commentThread); this._commentReply?.updateCommentThread(commentThread); diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts index 2582bfd77b4..5c9e312b6fe 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts @@ -327,13 +327,9 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget } } - if (shouldMoveWidget && this._isExpanded) { + if ((shouldMoveWidget && this._isExpanded) || (this._commentThread.collapsibleState === languages.CommentThreadCollapsibleState.Expanded && !this._isExpanded)) { this.show(this.arrowPosition(this._commentThread.range), 2); - } - - if (this._commentThread.collapsibleState === languages.CommentThreadCollapsibleState.Expanded) { - this.show(this.arrowPosition(this._commentThread.range), 2); - } else { + } else if (this._commentThread.collapsibleState !== languages.CommentThreadCollapsibleState.Expanded) { this.hide(); } }