mirror of
https://github.com/Microsoft/vscode
synced 2024-11-05 18:29:38 +00:00
Make CommentThread Ctrl+Arrow navigible (#189913)
This commit is contained in:
parent
e83b87f96c
commit
8a7aecc3b9
2 changed files with 25 additions and 0 deletions
|
@ -152,6 +152,15 @@ export class CommentReply<T extends IRange | ICellRange> extends Disposable {
|
|||
this.commentEditor.focus();
|
||||
}
|
||||
|
||||
public expandReplyAreaAndFocusCommentEditor() {
|
||||
this.expandReplyArea();
|
||||
this.commentEditor.focus();
|
||||
}
|
||||
|
||||
public isCommentEditorFocused(): boolean {
|
||||
return this.commentEditor.hasWidgetFocus();
|
||||
}
|
||||
|
||||
public getCommentModel() {
|
||||
return this.commentEditor.getModel()!;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import { commentThreadStateBackgroundColorVar, commentThreadStateColorVar } from
|
|||
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
|
||||
import { FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
|
||||
|
||||
export const COMMENTEDITOR_DECORATION_KEY = 'commenteditordecoration';
|
||||
|
||||
|
@ -91,6 +92,21 @@ export class CommentThreadWidget<T extends IRange | ICellRange = IRange> extends
|
|||
const bodyElement = <HTMLDivElement>dom.$('.body');
|
||||
container.appendChild(bodyElement);
|
||||
|
||||
const tracker = this._register(dom.trackFocus(bodyElement));
|
||||
this._register(registerNavigableContainer({
|
||||
focusNotifiers: [tracker],
|
||||
focusNextWidget: () => {
|
||||
if (!this._commentReply?.isCommentEditorFocused()) {
|
||||
this._commentReply?.expandReplyAreaAndFocusCommentEditor();
|
||||
}
|
||||
},
|
||||
focusPreviousWidget: () => {
|
||||
if (this._commentReply?.isCommentEditorFocused() && this._commentThread.comments?.length) {
|
||||
this._body.focus();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
this._body = this._scopedInstatiationService.createInstance(
|
||||
CommentThreadBody,
|
||||
this._owner,
|
||||
|
|
Loading…
Reference in a new issue