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 4 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 @@ -49,6 +49,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 @@ -29,8 +29,6 @@ import './quickInputActions.js';
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 @@ -731,7 +729,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 @@ -70,6 +70,8 @@ export class QuickInputService extends Themable implements IQuickInputService {
idPrefix: 'quickInput_',
container: host.activeContainer,
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 @@ -80,6 +80,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 @@ -490,6 +490,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.experimental.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
Tyriar marked this conversation as resolved.
Show resolved Hide resolved
},
'workbench.quickOpen.experimental.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.5,
'maximum': 0.9
},
'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 @@ -14,6 +14,7 @@ import { QuickInputService as BaseQuickInputService } from '../../../../platform
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js';
import { InQuickPickContextKey } from '../../../browser/quickaccess.js';
import { clamp } from '../../../../base/common/numbers.js';

export class QuickInputService extends BaseQuickInputService {

Expand All @@ -40,6 +41,8 @@ export class QuickInputService extends BaseQuickInputService {
protected override createController(): QuickInputController {
return super.createController(this.layoutService, {
ignoreFocusOut: () => !this.configurationService.getValue('workbench.quickOpen.closeOnFocusLost'),
maximumWidth: () => clamp(this.configurationService.getValue('workbench.quickOpen.experimental.maximumWidth'), 200, 2000),
relativeWidth: () => clamp(this.configurationService.getValue('workbench.quickOpen.experimental.relativeWidth'), 0.5, 0.9),
backKeybindingLabel: () => this.keybindingService.lookupKeybinding('workbench.action.quickInputBack')?.getLabel() || undefined,
});
}
Expand Down
Loading