Merge pull request #186724 from microsoft/aiday/focusOnEditor

On escape place focus back into editor
This commit is contained in:
Aiday Marlen Kyzy
2023-07-11 16:32:25 +02:00
committed by GitHub
2 changed files with 1 additions and 44 deletions
@@ -395,10 +395,6 @@ export class ContentHoverController extends Disposable {
public goToBottom(): void {
this._widget.goToBottom();
}
public escape(): void {
this._widget.escape();
}
}
class HoverResult {
@@ -730,7 +726,7 @@ export class ContentHoverWidget extends ResizableContentWidget {
if (!this._visibleData) {
return;
}
const stoleFocus = this._visibleData.stoleFocus;
const stoleFocus = this._visibleData.stoleFocus || this._hoverFocusedKey.get();
this._setHoverData(undefined);
this._resizableNode.maxSize = new dom.Dimension(Infinity, Infinity);
this._resizableNode.clearSashHoverState();
@@ -822,10 +818,6 @@ export class ContentHoverWidget extends ResizableContentWidget {
public goToBottom(): void {
this._hover.scrollbar.setScrollPosition({ scrollTop: this._hover.scrollbar.getScrollDimensions().scrollHeight });
}
public escape(): void {
this._editor.focus();
}
}
export class EditorHoverStatusBar extends Disposable implements IEditorHoverStatusBar {
@@ -302,10 +302,6 @@ export class ModesHoverController implements IEditorContribution {
this._contentWidget?.goToBottom();
}
public escape(): void {
this._contentWidget?.escape();
}
public isHoverVisible(): boolean | undefined {
return this._contentWidget?.isVisible();
}
@@ -665,36 +661,6 @@ class GoToBottomHoverAction extends EditorAction {
}
}
class EscapeFocusHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.escapeFocusHover',
label: nls.localize({
key: 'escapeFocusHover',
comment: [
'Action that allows to escape from the hover widget with the escape command when the hover widget is focused.'
]
}, "Escape Focus Hover"),
alias: 'Escape Focus Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.Escape,
weight: KeybindingWeight.EditorContrib
}
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = ModesHoverController.get(editor);
if (!controller) {
return;
}
controller.escape();
}
}
registerEditorContribution(ModesHoverController.ID, ModesHoverController, EditorContributionInstantiation.BeforeFirstInteraction);
registerEditorAction(ShowOrFocusHoverAction);
registerEditorAction(ShowDefinitionPreviewHoverAction);
@@ -706,7 +672,6 @@ registerEditorAction(PageUpHoverAction);
registerEditorAction(PageDownHoverAction);
registerEditorAction(GoToTopHoverAction);
registerEditorAction(GoToBottomHoverAction);
registerEditorAction(EscapeFocusHoverAction);
HoverParticipantRegistry.register(MarkdownHoverParticipant);
HoverParticipantRegistry.register(MarkerHoverParticipant);