mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
fixes #107580
This commit is contained in:
parent
9382e6375f
commit
39da5d0546
|
@ -19,6 +19,8 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
|||
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { isAncestor } from 'vs/base/browser/dom';
|
||||
|
||||
abstract class BaseNavigationAction extends Action {
|
||||
|
||||
|
@ -215,8 +217,8 @@ function findVisibleNeighbour(layoutService: IWorkbenchLayoutService, part: Part
|
|||
return findVisibleNeighbour(layoutService, neighbour, next);
|
||||
}
|
||||
|
||||
function focusNextOrPreviousPart(layoutService: IWorkbenchLayoutService, next: boolean): void {
|
||||
const currentlyFocusedPart = layoutService.hasFocus(Parts.EDITOR_PART) ? Parts.EDITOR_PART : layoutService.hasFocus(Parts.ACTIVITYBAR_PART) ? Parts.ACTIVITYBAR_PART :
|
||||
function focusNextOrPreviousPart(layoutService: IWorkbenchLayoutService, editorService: IEditorService, next: boolean): void {
|
||||
const currentlyFocusedPart = isActiveElementInNotebookEditor(editorService) ? Parts.EDITOR_PART : layoutService.hasFocus(Parts.EDITOR_PART) ? Parts.EDITOR_PART : layoutService.hasFocus(Parts.ACTIVITYBAR_PART) ? Parts.ACTIVITYBAR_PART :
|
||||
layoutService.hasFocus(Parts.STATUSBAR_PART) ? Parts.STATUSBAR_PART : layoutService.hasFocus(Parts.SIDEBAR_PART) ? Parts.SIDEBAR_PART : layoutService.hasFocus(Parts.PANEL_PART) ? Parts.PANEL_PART : undefined;
|
||||
let partToFocus = Parts.EDITOR_PART;
|
||||
if (currentlyFocusedPart) {
|
||||
|
@ -226,6 +228,17 @@ function focusNextOrPreviousPart(layoutService: IWorkbenchLayoutService, next: b
|
|||
layoutService.focusPart(partToFocus);
|
||||
}
|
||||
|
||||
function isActiveElementInNotebookEditor(editorService: IEditorService): boolean {
|
||||
const activeEditorPane = editorService.activeEditorPane as unknown as { isNotebookEditor?: boolean } | undefined;
|
||||
if (activeEditorPane?.isNotebookEditor) {
|
||||
const control = editorService.activeEditorPane?.getControl() as { getDomNode(): HTMLElement; getOverflowContainerDomNode(): HTMLElement; };
|
||||
const activeElement = document.activeElement;
|
||||
return isAncestor(activeElement, control.getDomNode()) || isAncestor(activeElement, control.getOverflowContainerDomNode());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export class FocusNextPart extends Action {
|
||||
static readonly ID = 'workbench.action.focusNextPart';
|
||||
static readonly LABEL = nls.localize('focusNextPart', "Focus Next Part");
|
||||
|
@ -233,13 +246,14 @@ export class FocusNextPart extends Action {
|
|||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
|
||||
@IEditorService private readonly editorService: IEditorService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
focusNextOrPreviousPart(this.layoutService, true);
|
||||
focusNextOrPreviousPart(this.layoutService, this.editorService, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,13 +264,14 @@ export class FocusPreviousPart extends Action {
|
|||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
|
||||
@IEditorService private readonly editorService: IEditorService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
focusNextOrPreviousPart(this.layoutService, false);
|
||||
focusNextOrPreviousPart(this.layoutService, this.editorService, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue