diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 634fad15a96..a2ae342dde3 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -46,6 +46,7 @@ import { ILayoutService, IDimension } from 'vs/platform/layout/browser/layoutSer import { SimpleServicesNLS } from 'vs/editor/common/standaloneStrings'; import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings'; import { basename } from 'vs/base/common/resources'; +import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; export class SimpleModel implements IResolvedTextEditorModel { @@ -744,5 +745,9 @@ export class SimpleLayoutService implements ILayoutService { return this._container; } - constructor(private _container: HTMLElement) { } + focus(): void { + this._codeEditorService.getActiveCodeEditor()?.focus(); + } + + constructor(private _codeEditorService: ICodeEditorService, private _container: HTMLElement) { } } diff --git a/src/vs/editor/standalone/browser/standaloneServices.ts b/src/vs/editor/standalone/browser/standaloneServices.ts index b92c8ae812c..0ee9ba495d0 100644 --- a/src/vs/editor/standalone/browser/standaloneServices.ts +++ b/src/vs/editor/standalone/browser/standaloneServices.ts @@ -206,7 +206,7 @@ export class DynamicStandaloneServices extends Disposable { let keybindingService = ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement))); - let layoutService = ensure(ILayoutService, () => new SimpleLayoutService(domElement)); + let layoutService = ensure(ILayoutService, () => new SimpleLayoutService(StaticServices.codeEditorService.get(ICodeEditorService), domElement)); let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(layoutService))); diff --git a/src/vs/platform/layout/browser/layoutService.ts b/src/vs/platform/layout/browser/layoutService.ts index 4da1b795207..988c518cfff 100644 --- a/src/vs/platform/layout/browser/layoutService.ts +++ b/src/vs/platform/layout/browser/layoutService.ts @@ -37,4 +37,9 @@ export interface ILayoutService { * event carries the dimensions of the container as part of it. */ readonly onLayout: Event; + + /** + * Focus the primary component of the container. + */ + focus(): void; } diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index f545492b078..ae802119f6f 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -663,6 +663,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi return true; // any other part cannot be hidden } + focus(): void { + this.editorGroupService.activeGroup.focus(); + } + getDimension(part: Parts): Dimension | undefined { return this.getPart(part).dimension; } @@ -806,7 +810,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi // Status bar and activity bar visibility come from settings -> update their visibility. this.doUpdateLayoutConfiguration(true); - this.editorGroupService.activeGroup.focus(); + this.focus(); if (this.state.zenMode.setNotificationsFilter) { this.notificationService.setFilter(NotificationsFilter.OFF); } @@ -1090,7 +1094,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi if (this.hasFocus(Parts.PANEL_PART) && activePanel) { activePanel.focus(); } else { - this.editorGroupService.activeGroup.focus(); + this.focus(); } } diff --git a/src/vs/workbench/browser/parts/quickinput/quickInput.ts b/src/vs/workbench/browser/parts/quickinput/quickInput.ts index 206d73a498c..864500291df 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInput.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInput.ts @@ -12,12 +12,10 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { CancellationToken } from 'vs/base/common/cancellation'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { CLOSE_ON_FOCUS_LOST_CONFIG } from 'vs/workbench/browser/quickopen'; import { computeStyles } from 'vs/platform/theme/common/styler'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; -import { ICommandAndKeybindingRule, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { ICommandAndKeybindingRule, KeybindingWeight, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { inQuickOpenContext, InQuickOpenContextKey } from 'vs/workbench/browser/parts/quickopen/quickopen'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; @@ -48,7 +46,6 @@ export class QuickInputService extends PlatformQuickInputService { @IEnvironmentService private readonly environmentService: IEnvironmentService, @IConfigurationService private readonly configurationService: IConfigurationService, @IInstantiationService private readonly instantiationService: IInstantiationService, - @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService, @IKeybindingService private readonly keybindingService: IKeybindingService, @IContextKeyService private readonly contextKeyService: IContextKeyService, @IThemeService themeService: IThemeService, @@ -60,11 +57,11 @@ export class QuickInputService extends PlatformQuickInputService { this.controller = this._register(new QuickInputController({ idPrefix: 'quickInput_', // Constant since there is still only one. container: this.layoutService.container, - ignoreFocusOut: () => this.environmentService.args['sticky-quickopen'] || !this.configurationService.getValue(CLOSE_ON_FOCUS_LOST_CONFIG), + ignoreFocusOut: () => this.environmentService.args['sticky-quickopen'] || !this.configurationService.getValue('workbench.quickOpen.closeOnFocusLost'), isScreenReaderOptimized: () => this.accessibilityService.isScreenReaderOptimized(), backKeybindingLabel: () => this.keybindingService.lookupKeybinding(QuickPickBack.id)?.getLabel() || undefined, setContextKey: (id?: string) => this.setContextKey(id), - returnFocus: () => this.editorGroupService.activeGroup.focus(), + returnFocus: () => this.layoutService.focus(), createList: ( user: string, container: HTMLElement, @@ -246,6 +243,16 @@ export const QuickPickBack: ICommandAndKeybindingRule = { } }; +KeybindingsRegistry.registerCommandAndKeybindingRule(QuickPickManyToggle); +KeybindingsRegistry.registerCommandAndKeybindingRule(QuickPickBack); + +registerSingleton(IQuickInputService, QuickInputService, true); + + + + + + // TODO@Ben delete eventually when quick open is implemented using quick input export class LegacyQuickInputQuickOpenController extends Disposable { @@ -298,5 +305,3 @@ export class LegacyQuickInputQuickOpenController extends Disposable { } Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(LegacyQuickInputQuickOpenController, LifecyclePhase.Ready); - -registerSingleton(IQuickInputService, QuickInputService, true); diff --git a/src/vs/workbench/browser/parts/quickinput/quickInputActions.ts b/src/vs/workbench/browser/parts/quickinput/quickInputActions.ts deleted file mode 100644 index a41fff2101b..00000000000 --- a/src/vs/workbench/browser/parts/quickinput/quickInputActions.ts +++ /dev/null @@ -1,10 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { QuickPickManyToggle, QuickPickBack } from 'vs/workbench/browser/parts/quickinput/quickInput'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; - -KeybindingsRegistry.registerCommandAndKeybindingRule(QuickPickManyToggle); -KeybindingsRegistry.registerCommandAndKeybindingRule(QuickPickBack); diff --git a/src/vs/workbench/test/browser/workbenchTestServices.ts b/src/vs/workbench/test/browser/workbenchTestServices.ts index 4771f4dd028..0b47f216620 100644 --- a/src/vs/workbench/test/browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/browser/workbenchTestServices.ts @@ -406,6 +406,7 @@ export class TestLayoutService implements IWorkbenchLayoutService { isWindowMaximized() { return false; } updateWindowMaximizedState(maximized: boolean): void { } getVisibleNeighborPart(part: Parts, direction: Direction): Parts | undefined { return undefined; } + focus() { } } let activeViewlet: Viewlet = {} as any; diff --git a/src/vs/workbench/workbench.common.main.ts b/src/vs/workbench/workbench.common.main.ts index 5f617430c22..f528738e5e5 100644 --- a/src/vs/workbench/workbench.common.main.ts +++ b/src/vs/workbench/workbench.common.main.ts @@ -26,7 +26,6 @@ import 'vs/workbench/browser/actions/workspaceActions'; import 'vs/workbench/browser/actions/workspaceCommands'; import 'vs/workbench/browser/parts/quickopen/quickOpenActions'; -import 'vs/workbench/browser/parts/quickinput/quickInputActions'; //#endregion