Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove arbitrary 600 pixel limit on quick input widget #117862

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/vs/platform/quickinput/browser/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface IQuickInputOptions {
idPrefix: string;
container: HTMLElement;
ignoreFocusOut(): boolean;
maximumWidth(): number;
relativeWidth(): number;
backKeybindingLabel(): string | undefined;
setContextKey(id?: string): void;
linkOpenerDelegate(content: string): void;
Expand Down
4 changes: 1 addition & 3 deletions src/vs/platform/quickinput/browser/quickInputController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
const $ = dom.$;

export class QuickInputController extends Disposable {
private static readonly MAX_WIDTH = 600; // Max total width of quick input widget

private idPrefix: string;
private ui: QuickInputUI | undefined;
private dimension?: dom.IDimension;
Expand Down Expand Up @@ -652,7 +650,7 @@ export class QuickInputController extends Disposable {
this.ui.container.style.top = `${this.titleBarOffset}px`;

const style = this.ui.container.style;
const width = Math.min(this.dimension!.width * 0.62 /* golden cut */, QuickInputController.MAX_WIDTH);
const width = Math.min(this.dimension!.width * this.options.relativeWidth(), this.options.maximumWidth());
style.width = width + 'px';
style.marginLeft = '-' + (width / 2) + 'px';

Expand Down
2 changes: 2 additions & 0 deletions src/vs/platform/quickinput/browser/quickInputService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export class QuickInputService extends Themable implements IQuickInputService {
idPrefix: 'quickInput_',
container: host.container,
ignoreFocusOut: () => false,
maximumWidth: () => 600,
relativeWidth: () => 0.62,
backKeybindingLabel: () => undefined,
setContextKey: (id?: string) => this.setContextKey(id),
linkOpenerDelegate: (content) => {
Expand Down
2 changes: 2 additions & 0 deletions src/vs/platform/quickinput/test/browser/quickinput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ suite('QuickInput', () => { // https://github.com/microsoft/vscode/issues/147543
container: fixture,
idPrefix: 'testQuickInput',
ignoreFocusOut() { return true; },
maximumWidth() { return 600; },
relativeWidth() { return 0.62; },
returnFocus() { },
backKeybindingLabel() { return undefined; },
setContextKey() { return undefined; },
Expand Down
14 changes: 14 additions & 0 deletions src/vs/workbench/browser/workbench.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,20 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
'description': localize('workbench.quickOpen.preserveInput', "Controls whether the last typed input to Quick Open should be restored when opening it the next time."),
'default': false
},
'workbench.quickOpen.maximumWidth': {
'type': 'number',
'description': localize('workbench.quickOpen.maxWidth', "Limits the maximum width of Quick Open to the specified number of pixels."),
'default': 600,
'minimum': 200,
'maximum': 2000
},
'workbench.quickOpen.relativeWidth': {
'type': 'number',
'description': localize('workbench.quickOpen.relativeWidth', "Controls the width of Quick Open relative to the total window width."),
'default': 0.62,
'minimum': 0.1,
'maximum': 1.0
},
'workbench.settings.openDefaultSettings': {
'type': 'boolean',
'description': localize('openDefaultSettings', "Controls whether opening settings also opens an editor showing all default settings."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class QuickInputService extends BaseQuickInputService {
protected override createController(): QuickInputController {
return super.createController(this.layoutService, {
ignoreFocusOut: () => !this.configurationService.getValue('workbench.quickOpen.closeOnFocusLost'),
maximumWidth: () => this.configurationService.getValue('workbench.quickOpen.maximumWidth'),
relativeWidth: () => this.configurationService.getValue('workbench.quickOpen.relativeWidth'),
backKeybindingLabel: () => this.keybindingService.lookupKeybinding('workbench.action.quickInputBack')?.getLabel() || undefined,
hoverDelegate: this.hoverDelegate
});
Expand Down