From e44296c03ea36ae833de82cc90754385fdc569b0 Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Fri, 30 Jun 2023 16:37:15 +0600 Subject: [PATCH 1/2] placing back the focus on the editor in all cases and removing the escape action --- .../contrib/hover/browser/contentHover.ts | 13 +------ src/vs/editor/contrib/hover/browser/hover.ts | 35 ------------------- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/src/vs/editor/contrib/hover/browser/contentHover.ts b/src/vs/editor/contrib/hover/browser/contentHover.ts index f03cf308b61..67b790508b2 100644 --- a/src/vs/editor/contrib/hover/browser/contentHover.ts +++ b/src/vs/editor/contrib/hover/browser/contentHover.ts @@ -395,10 +395,6 @@ export class ContentHoverController extends Disposable { public goToBottom(): void { this._widget.goToBottom(); } - - public escape(): void { - this._widget.escape(); - } } class HoverResult { @@ -730,15 +726,12 @@ export class ContentHoverWidget extends ResizableContentWidget { if (!this._visibleData) { return; } - const stoleFocus = this._visibleData.stoleFocus; this._setHoverData(undefined); this._resizableNode.maxSize = new dom.Dimension(Infinity, Infinity); this._resizableNode.clearSashHoverState(); this._hoverFocusedKey.set(false); this._editor.layoutContentWidget(this); - if (stoleFocus) { - this._editor.focus(); - } + this._editor.focus(); } private _removeConstraintsRenderNormally(): void { @@ -822,10 +815,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 { diff --git a/src/vs/editor/contrib/hover/browser/hover.ts b/src/vs/editor/contrib/hover/browser/hover.ts index 881435fe4c9..46c94e313df 100644 --- a/src/vs/editor/contrib/hover/browser/hover.ts +++ b/src/vs/editor/contrib/hover/browser/hover.ts @@ -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); From 0ccb215397ced6315dc5851a5f01f566b0fcdb9b Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Mon, 10 Jul 2023 13:05:18 +0200 Subject: [PATCH 2/2] making stole focus also check whether the hover focused key is set to true --- src/vs/editor/contrib/hover/browser/contentHover.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/contrib/hover/browser/contentHover.ts b/src/vs/editor/contrib/hover/browser/contentHover.ts index 67b790508b2..170d097fe80 100644 --- a/src/vs/editor/contrib/hover/browser/contentHover.ts +++ b/src/vs/editor/contrib/hover/browser/contentHover.ts @@ -726,12 +726,15 @@ export class ContentHoverWidget extends ResizableContentWidget { if (!this._visibleData) { return; } + const stoleFocus = this._visibleData.stoleFocus || this._hoverFocusedKey.get(); this._setHoverData(undefined); this._resizableNode.maxSize = new dom.Dimension(Infinity, Infinity); this._resizableNode.clearSashHoverState(); this._hoverFocusedKey.set(false); this._editor.layoutContentWidget(this); - this._editor.focus(); + if (stoleFocus) { + this._editor.focus(); + } } private _removeConstraintsRenderNormally(): void {