Skip to content

Commit c3acc8d

Browse files
authored
Merge pull request microsoft#186724 from microsoft/aiday/focusOnEditor
On escape place focus back into editor
2 parents dca0fc0 + 0ccb215 commit c3acc8d

File tree

2 files changed

+1
-44
lines changed

2 files changed

+1
-44
lines changed

src/vs/editor/contrib/hover/browser/contentHover.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,6 @@ export class ContentHoverController extends Disposable {
395395
public goToBottom(): void {
396396
this._widget.goToBottom();
397397
}
398-
399-
public escape(): void {
400-
this._widget.escape();
401-
}
402398
}
403399

404400
class HoverResult {
@@ -730,7 +726,7 @@ export class ContentHoverWidget extends ResizableContentWidget {
730726
if (!this._visibleData) {
731727
return;
732728
}
733-
const stoleFocus = this._visibleData.stoleFocus;
729+
const stoleFocus = this._visibleData.stoleFocus || this._hoverFocusedKey.get();
734730
this._setHoverData(undefined);
735731
this._resizableNode.maxSize = new dom.Dimension(Infinity, Infinity);
736732
this._resizableNode.clearSashHoverState();
@@ -822,10 +818,6 @@ export class ContentHoverWidget extends ResizableContentWidget {
822818
public goToBottom(): void {
823819
this._hover.scrollbar.setScrollPosition({ scrollTop: this._hover.scrollbar.getScrollDimensions().scrollHeight });
824820
}
825-
826-
public escape(): void {
827-
this._editor.focus();
828-
}
829821
}
830822

831823
export class EditorHoverStatusBar extends Disposable implements IEditorHoverStatusBar {

src/vs/editor/contrib/hover/browser/hover.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,6 @@ export class ModesHoverController implements IEditorContribution {
302302
this._contentWidget?.goToBottom();
303303
}
304304

305-
public escape(): void {
306-
this._contentWidget?.escape();
307-
}
308-
309305
public isHoverVisible(): boolean | undefined {
310306
return this._contentWidget?.isVisible();
311307
}
@@ -665,36 +661,6 @@ class GoToBottomHoverAction extends EditorAction {
665661
}
666662
}
667663

668-
class EscapeFocusHoverAction extends EditorAction {
669-
670-
constructor() {
671-
super({
672-
id: 'editor.action.escapeFocusHover',
673-
label: nls.localize({
674-
key: 'escapeFocusHover',
675-
comment: [
676-
'Action that allows to escape from the hover widget with the escape command when the hover widget is focused.'
677-
]
678-
}, "Escape Focus Hover"),
679-
alias: 'Escape Focus Hover',
680-
precondition: EditorContextKeys.hoverFocused,
681-
kbOpts: {
682-
kbExpr: EditorContextKeys.hoverFocused,
683-
primary: KeyCode.Escape,
684-
weight: KeybindingWeight.EditorContrib
685-
}
686-
});
687-
}
688-
689-
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
690-
const controller = ModesHoverController.get(editor);
691-
if (!controller) {
692-
return;
693-
}
694-
controller.escape();
695-
}
696-
}
697-
698664
registerEditorContribution(ModesHoverController.ID, ModesHoverController, EditorContributionInstantiation.BeforeFirstInteraction);
699665
registerEditorAction(ShowOrFocusHoverAction);
700666
registerEditorAction(ShowDefinitionPreviewHoverAction);
@@ -706,7 +672,6 @@ registerEditorAction(PageUpHoverAction);
706672
registerEditorAction(PageDownHoverAction);
707673
registerEditorAction(GoToTopHoverAction);
708674
registerEditorAction(GoToBottomHoverAction);
709-
registerEditorAction(EscapeFocusHoverAction);
710675
HoverParticipantRegistry.register(MarkdownHoverParticipant);
711676
HoverParticipantRegistry.register(MarkerHoverParticipant);
712677

0 commit comments

Comments
 (0)