Skip to content

Commit

Permalink
Follow enter vs. space focus vs. reveal convention
Browse files Browse the repository at this point in the history
Part of #192377
  • Loading branch information
alexr00 committed Sep 18, 2023
1 parent fd684a2 commit a17733b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ 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);
if (focus) {
this._commentThreadWidget.focus();
}
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,18 +600,18 @@ export class CommentController implements IEditorContribution {
return editor.getContribution<CommentController>(ID);
}

public revealCommentThread(threadId: string, commentUniqueId: number, fetchOnceIfNotExist: boolean): void {
public revealCommentThread(threadId: string, commentUniqueId: number, fetchOnceIfNotExist: boolean, focus: boolean): void {
const commentThreadWidget = this._commentWidgets.filter(widget => widget.commentThread.threadId === threadId);
if (commentThreadWidget.length === 1) {
commentThreadWidget[0].reveal(commentUniqueId);
commentThreadWidget[0].reveal(commentUniqueId, focus);
} else if (fetchOnceIfNotExist) {
if (this._computePromise) {
this._computePromise.then(_ => {
this.revealCommentThread(threadId, commentUniqueId, false);
this.revealCommentThread(threadId, commentUniqueId, false, focus);
});
} else {
this.beginCompute().then(_ => {
this.revealCommentThread(threadId, commentUniqueId, false);
this.revealCommentThread(threadId, commentUniqueId, false, focus);
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/comments/browser/commentsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
const commentToReveal = element instanceof ResourceWithCommentThreads ? element.commentThreads[0].comment.uniqueIdInThread : element.comment.uniqueIdInThread;
if (threadToReveal && isCodeEditor(editor)) {
const controller = CommentController.get(editor);
controller?.revealCommentThread(threadToReveal, commentToReveal, true);
controller?.revealCommentThread(threadToReveal, commentToReveal, true, !preserveFocus);
}

return true;
Expand All @@ -421,7 +421,7 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
const control = editor.getControl();
if (threadToReveal && isCodeEditor(control)) {
const controller = CommentController.get(control);
controller?.revealCommentThread(threadToReveal, commentToReveal.uniqueIdInThread, true);
controller?.revealCommentThread(threadToReveal, commentToReveal.uniqueIdInThread, true, !preserveFocus);
}
}
});
Expand Down

0 comments on commit a17733b

Please sign in to comment.