quick input - lift workbench specific parts up
This commit is contained in:
parent
811c4b5552
commit
1370ae0098
4 changed files with 55 additions and 21 deletions
|
@ -10,10 +10,7 @@ import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||||
import { IQuickInputService, IQuickInputButton, IQuickPickItem, IQuickPick, IInputBox, IQuickNavigateConfiguration, IPickOptions, QuickPickInput, IInputOptions } from 'vs/platform/quickinput/common/quickInput';
|
import { IQuickInputService, IQuickInputButton, IQuickPickItem, IQuickPick, IInputBox, IQuickNavigateConfiguration, IPickOptions, QuickPickInput, IInputOptions } from 'vs/platform/quickinput/common/quickInput';
|
||||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
|
||||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||||
|
@ -28,15 +25,13 @@ export class EditorScopedQuickInputServiceImpl extends QuickInputService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
editor: ICodeEditor,
|
editor: ICodeEditor,
|
||||||
@IConfigurationService configurationService: IConfigurationService,
|
|
||||||
@IInstantiationService instantiationService: IInstantiationService,
|
@IInstantiationService instantiationService: IInstantiationService,
|
||||||
@IKeybindingService keybindingService: IKeybindingService,
|
|
||||||
@IContextKeyService contextKeyService: IContextKeyService,
|
@IContextKeyService contextKeyService: IContextKeyService,
|
||||||
@IThemeService themeService: IThemeService,
|
@IThemeService themeService: IThemeService,
|
||||||
@IAccessibilityService accessibilityService: IAccessibilityService,
|
@IAccessibilityService accessibilityService: IAccessibilityService,
|
||||||
@ILayoutService layoutService: ILayoutService
|
@ILayoutService layoutService: ILayoutService
|
||||||
) {
|
) {
|
||||||
super({ args: Object.create(null) } as IEnvironmentService, configurationService, instantiationService, keybindingService, contextKeyService, themeService, accessibilityService, layoutService);
|
super(instantiationService, contextKeyService, themeService, accessibilityService, layoutService);
|
||||||
|
|
||||||
// Use the passed in code editor as host for the quick input widget
|
// Use the passed in code editor as host for the quick input widget
|
||||||
const contribution = QuickInputEditorContribution.get(editor);
|
const contribution = QuickInputEditorContribution.get(editor);
|
||||||
|
|
|
@ -9,13 +9,10 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||||
import { IThemeService, Themable } from 'vs/platform/theme/common/themeService';
|
import { IThemeService, Themable } from 'vs/platform/theme/common/themeService';
|
||||||
import { inputBackground, inputForeground, inputBorder, inputValidationInfoBackground, inputValidationInfoForeground, inputValidationInfoBorder, inputValidationWarningBackground, inputValidationWarningForeground, inputValidationWarningBorder, inputValidationErrorBackground, inputValidationErrorForeground, inputValidationErrorBorder, badgeBackground, badgeForeground, contrastBorder, buttonForeground, buttonBackground, buttonHoverBackground, progressBarBackground, widgetShadow, listFocusForeground, listFocusBackground, activeContrastBorder, pickerGroupBorder, pickerGroupForeground, quickInputForeground, quickInputBackground, quickInputTitleBackground } from 'vs/platform/theme/common/colorRegistry';
|
import { inputBackground, inputForeground, inputBorder, inputValidationInfoBackground, inputValidationInfoForeground, inputValidationInfoBorder, inputValidationWarningBackground, inputValidationWarningForeground, inputValidationWarningBorder, inputValidationErrorBackground, inputValidationErrorForeground, inputValidationErrorBorder, badgeBackground, badgeForeground, contrastBorder, buttonForeground, buttonBackground, buttonHoverBackground, progressBarBackground, widgetShadow, listFocusForeground, listFocusBackground, activeContrastBorder, pickerGroupBorder, pickerGroupForeground, quickInputForeground, quickInputBackground, quickInputTitleBackground } from 'vs/platform/theme/common/colorRegistry';
|
||||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
|
||||||
import { computeStyles } from 'vs/platform/theme/common/styler';
|
import { computeStyles } from 'vs/platform/theme/common/styler';
|
||||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
|
||||||
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
|
||||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||||
import { QuickInputController, IQuickInputStyles } from 'vs/base/parts/quickinput/browser/quickInput';
|
import { QuickInputController, IQuickInputStyles, IQuickInputOptions } from 'vs/base/parts/quickinput/browser/quickInput';
|
||||||
import { WorkbenchList } from 'vs/platform/list/browser/listService';
|
import { WorkbenchList } from 'vs/platform/list/browser/listService';
|
||||||
import { List, IListOptions } from 'vs/base/browser/ui/list/listWidget';
|
import { List, IListOptions } from 'vs/base/browser/ui/list/listWidget';
|
||||||
import { IListVirtualDelegate, IListRenderer } from 'vs/base/browser/ui/list/list';
|
import { IListVirtualDelegate, IListRenderer } from 'vs/base/browser/ui/list/list';
|
||||||
|
@ -43,25 +40,22 @@ export class QuickInputService extends Themable implements IQuickInputService {
|
||||||
private readonly contexts = new Map<string, IContextKey<boolean>>();
|
private readonly contexts = new Map<string, IContextKey<boolean>>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
|
||||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
|
||||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||||
@IKeybindingService private readonly keybindingService: IKeybindingService,
|
|
||||||
@IContextKeyService private readonly contextKeyService: IContextKeyService,
|
@IContextKeyService private readonly contextKeyService: IContextKeyService,
|
||||||
@IThemeService themeService: IThemeService,
|
@IThemeService themeService: IThemeService,
|
||||||
@IAccessibilityService private readonly accessibilityService: IAccessibilityService,
|
@IAccessibilityService private readonly accessibilityService: IAccessibilityService,
|
||||||
@ILayoutService private readonly layoutService: ILayoutService
|
@ILayoutService protected readonly layoutService: ILayoutService
|
||||||
) {
|
) {
|
||||||
super(themeService);
|
super(themeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createController(host: IQuickInputControllerHost = this.layoutService): QuickInputController {
|
protected createController(host: IQuickInputControllerHost = this.layoutService, options?: Partial<IQuickInputOptions>): QuickInputController {
|
||||||
const controller = this._register(new QuickInputController({
|
const defaultOptions: IQuickInputOptions = {
|
||||||
idPrefix: 'quickInput_', // Constant since there is still only one.
|
idPrefix: 'quickInput_', // Constant since there is still only one.
|
||||||
container: host.container,
|
container: host.container,
|
||||||
ignoreFocusOut: () => this.environmentService.args['sticky-quickopen'] || !this.configurationService.getValue('workbench.quickOpen.closeOnFocusLost'),
|
ignoreFocusOut: () => false,
|
||||||
isScreenReaderOptimized: () => this.accessibilityService.isScreenReaderOptimized(),
|
isScreenReaderOptimized: () => this.accessibilityService.isScreenReaderOptimized(),
|
||||||
backKeybindingLabel: () => this.keybindingService.lookupKeybinding('workbench.action.quickInputBack')?.getLabel() || undefined,
|
backKeybindingLabel: () => undefined,
|
||||||
setContextKey: (id?: string) => this.setContextKey(id),
|
setContextKey: (id?: string) => this.setContextKey(id),
|
||||||
returnFocus: () => host.focus(),
|
returnFocus: () => host.focus(),
|
||||||
createList: <T>(
|
createList: <T>(
|
||||||
|
@ -72,6 +66,11 @@ export class QuickInputService extends Themable implements IQuickInputService {
|
||||||
options: IListOptions<T>,
|
options: IListOptions<T>,
|
||||||
) => this.instantiationService.createInstance(WorkbenchList, user, container, delegate, renderers, options) as List<T>,
|
) => this.instantiationService.createInstance(WorkbenchList, user, container, delegate, renderers, options) as List<T>,
|
||||||
styles: this.computeStyles()
|
styles: this.computeStyles()
|
||||||
|
};
|
||||||
|
|
||||||
|
const controller = this._register(new QuickInputController({
|
||||||
|
...defaultOptions,
|
||||||
|
...options
|
||||||
}));
|
}));
|
||||||
|
|
||||||
controller.layout(host.dimension, host.offset?.top ?? 0);
|
controller.layout(host.dimension, host.offset?.top ?? 0);
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||||
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||||
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
|
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||||
|
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||||
|
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||||
|
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||||
|
import { QuickInputController } from 'vs/base/parts/quickinput/browser/quickInput';
|
||||||
|
import { QuickInputService as BaseQuickInputService } from 'vs/platform/quickinput/browser/quickInput';
|
||||||
|
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||||
|
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
||||||
|
|
||||||
|
export class QuickInputService extends BaseQuickInputService {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||||
|
@IConfigurationService private configurationService: IConfigurationService,
|
||||||
|
@IInstantiationService instantiationService: IInstantiationService,
|
||||||
|
@IKeybindingService private keybindingService: IKeybindingService,
|
||||||
|
@IContextKeyService contextKeyService: IContextKeyService,
|
||||||
|
@IThemeService themeService: IThemeService,
|
||||||
|
@IAccessibilityService accessibilityService: IAccessibilityService,
|
||||||
|
@ILayoutService protected layoutService: ILayoutService
|
||||||
|
) {
|
||||||
|
super(instantiationService, contextKeyService, themeService, accessibilityService, layoutService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected createController(): QuickInputController {
|
||||||
|
return super.createController(this.layoutService, {
|
||||||
|
ignoreFocusOut: () => this.environmentService.args['sticky-quickopen'] || !this.configurationService.getValue('workbench.quickOpen.closeOnFocusLost'),
|
||||||
|
backKeybindingLabel: () => this.keybindingService.lookupKeybinding('workbench.action.quickInputBack')?.getLabel() || undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
registerSingleton(IQuickInputService, QuickInputService, true);
|
|
@ -84,6 +84,7 @@ import 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||||
import 'vs/workbench/services/workingCopy/common/workingCopyFileService';
|
import 'vs/workbench/services/workingCopy/common/workingCopyFileService';
|
||||||
import 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
import 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||||
import 'vs/workbench/services/views/browser/viewDescriptorService';
|
import 'vs/workbench/services/views/browser/viewDescriptorService';
|
||||||
|
import 'vs/workbench/services/quickinput/browser/quickInputService';
|
||||||
|
|
||||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
|
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
|
||||||
|
@ -112,8 +113,6 @@ import { OpenerService } from 'vs/editor/browser/services/openerService';
|
||||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||||
import { IUserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
|
import { IUserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
|
||||||
import { UserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSyncEnablementService';
|
import { UserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSyncEnablementService';
|
||||||
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
|
||||||
import { QuickInputService } from 'vs/platform/quickinput/browser/quickInput';
|
|
||||||
|
|
||||||
registerSingleton(IUserDataSyncEnablementService, UserDataSyncEnablementService);
|
registerSingleton(IUserDataSyncEnablementService, UserDataSyncEnablementService);
|
||||||
registerSingleton(IGlobalExtensionEnablementService, GlobalExtensionEnablementService);
|
registerSingleton(IGlobalExtensionEnablementService, GlobalExtensionEnablementService);
|
||||||
|
@ -129,7 +128,6 @@ registerSingleton(ITextResourceConfigurationService, TextResourceConfigurationSe
|
||||||
registerSingleton(IMenuService, MenuService, true);
|
registerSingleton(IMenuService, MenuService, true);
|
||||||
registerSingleton(IDownloadService, DownloadService, true);
|
registerSingleton(IDownloadService, DownloadService, true);
|
||||||
registerSingleton(IOpenerService, OpenerService, true);
|
registerSingleton(IOpenerService, OpenerService, true);
|
||||||
registerSingleton(IQuickInputService, QuickInputService, true);
|
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue