Skip to content

Commit 944a23d

Browse files
author
Benjamin Pasero
committed
quickpick - remove dependency to editor group service
1 parent bf21fb4 commit 944a23d

8 files changed

Lines changed: 32 additions & 23 deletions

File tree

src/vs/editor/standalone/browser/simpleServices.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { ILayoutService, IDimension } from 'vs/platform/layout/browser/layoutSer
4646
import { SimpleServicesNLS } from 'vs/editor/common/standaloneStrings';
4747
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
4848
import { basename } from 'vs/base/common/resources';
49+
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
4950

5051
export class SimpleModel implements IResolvedTextEditorModel {
5152

@@ -744,5 +745,9 @@ export class SimpleLayoutService implements ILayoutService {
744745
return this._container;
745746
}
746747

747-
constructor(private _container: HTMLElement) { }
748+
focus(): void {
749+
this._codeEditorService.getActiveCodeEditor()?.focus();
750+
}
751+
752+
constructor(private _codeEditorService: ICodeEditorService, private _container: HTMLElement) { }
748753
}

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export class DynamicStandaloneServices extends Disposable {
206206

207207
let keybindingService = ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement)));
208208

209-
let layoutService = ensure(ILayoutService, () => new SimpleLayoutService(domElement));
209+
let layoutService = ensure(ILayoutService, () => new SimpleLayoutService(StaticServices.codeEditorService.get(ICodeEditorService), domElement));
210210

211211
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(layoutService)));
212212

src/vs/platform/layout/browser/layoutService.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ export interface ILayoutService {
3737
* event carries the dimensions of the container as part of it.
3838
*/
3939
readonly onLayout: Event<IDimension>;
40+
41+
/**
42+
* Focus the primary component of the container.
43+
*/
44+
focus(): void;
4045
}

src/vs/workbench/browser/layout.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
663663
return true; // any other part cannot be hidden
664664
}
665665

666+
focus(): void {
667+
this.editorGroupService.activeGroup.focus();
668+
}
669+
666670
getDimension(part: Parts): Dimension | undefined {
667671
return this.getPart(part).dimension;
668672
}
@@ -806,7 +810,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
806810
// Status bar and activity bar visibility come from settings -> update their visibility.
807811
this.doUpdateLayoutConfiguration(true);
808812

809-
this.editorGroupService.activeGroup.focus();
813+
this.focus();
810814
if (this.state.zenMode.setNotificationsFilter) {
811815
this.notificationService.setFilter(NotificationsFilter.OFF);
812816
}
@@ -1090,7 +1094,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
10901094
if (this.hasFocus(Parts.PANEL_PART) && activePanel) {
10911095
activePanel.focus();
10921096
} else {
1093-
this.editorGroupService.activeGroup.focus();
1097+
this.focus();
10941098
}
10951099
}
10961100

src/vs/workbench/browser/parts/quickinput/quickInput.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
1212
import { CancellationToken } from 'vs/base/common/cancellation';
1313
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
1414
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
15-
import { CLOSE_ON_FOCUS_LOST_CONFIG } from 'vs/workbench/browser/quickopen';
1615
import { computeStyles } from 'vs/platform/theme/common/styler';
1716
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
18-
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
1917
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
20-
import { ICommandAndKeybindingRule, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
18+
import { ICommandAndKeybindingRule, KeybindingWeight, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
2119
import { inQuickOpenContext, InQuickOpenContextKey } from 'vs/workbench/browser/parts/quickopen/quickopen';
2220
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2321
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
@@ -48,7 +46,6 @@ export class QuickInputService extends PlatformQuickInputService {
4846
@IEnvironmentService private readonly environmentService: IEnvironmentService,
4947
@IConfigurationService private readonly configurationService: IConfigurationService,
5048
@IInstantiationService private readonly instantiationService: IInstantiationService,
51-
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
5249
@IKeybindingService private readonly keybindingService: IKeybindingService,
5350
@IContextKeyService private readonly contextKeyService: IContextKeyService,
5451
@IThemeService themeService: IThemeService,
@@ -60,11 +57,11 @@ export class QuickInputService extends PlatformQuickInputService {
6057
this.controller = this._register(new QuickInputController({
6158
idPrefix: 'quickInput_', // Constant since there is still only one.
6259
container: this.layoutService.container,
63-
ignoreFocusOut: () => this.environmentService.args['sticky-quickopen'] || !this.configurationService.getValue(CLOSE_ON_FOCUS_LOST_CONFIG),
60+
ignoreFocusOut: () => this.environmentService.args['sticky-quickopen'] || !this.configurationService.getValue('workbench.quickOpen.closeOnFocusLost'),
6461
isScreenReaderOptimized: () => this.accessibilityService.isScreenReaderOptimized(),
6562
backKeybindingLabel: () => this.keybindingService.lookupKeybinding(QuickPickBack.id)?.getLabel() || undefined,
6663
setContextKey: (id?: string) => this.setContextKey(id),
67-
returnFocus: () => this.editorGroupService.activeGroup.focus(),
64+
returnFocus: () => this.layoutService.focus(),
6865
createList: <T>(
6966
user: string,
7067
container: HTMLElement,
@@ -246,6 +243,16 @@ export const QuickPickBack: ICommandAndKeybindingRule = {
246243
}
247244
};
248245

246+
KeybindingsRegistry.registerCommandAndKeybindingRule(QuickPickManyToggle);
247+
KeybindingsRegistry.registerCommandAndKeybindingRule(QuickPickBack);
248+
249+
registerSingleton(IQuickInputService, QuickInputService, true);
250+
251+
252+
253+
254+
255+
249256
// TODO@Ben delete eventually when quick open is implemented using quick input
250257
export class LegacyQuickInputQuickOpenController extends Disposable {
251258

@@ -298,5 +305,3 @@ export class LegacyQuickInputQuickOpenController extends Disposable {
298305
}
299306

300307
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(LegacyQuickInputQuickOpenController, LifecyclePhase.Ready);
301-
302-
registerSingleton(IQuickInputService, QuickInputService, true);

src/vs/workbench/browser/parts/quickinput/quickInputActions.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/vs/workbench/test/browser/workbenchTestServices.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ export class TestLayoutService implements IWorkbenchLayoutService {
406406
isWindowMaximized() { return false; }
407407
updateWindowMaximizedState(maximized: boolean): void { }
408408
getVisibleNeighborPart(part: Parts, direction: Direction): Parts | undefined { return undefined; }
409+
focus() { }
409410
}
410411

411412
let activeViewlet: Viewlet = {} as any;

src/vs/workbench/workbench.common.main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import 'vs/workbench/browser/actions/workspaceActions';
2626
import 'vs/workbench/browser/actions/workspaceCommands';
2727

2828
import 'vs/workbench/browser/parts/quickopen/quickOpenActions';
29-
import 'vs/workbench/browser/parts/quickinput/quickInputActions';
3029

3130
//#endregion
3231

0 commit comments

Comments
 (0)