From 3fa1c26a64d773f607fc9e588d60568df28ceb7f Mon Sep 17 00:00:00 2001 From: Derek Scherger Date: Sun, 28 Feb 2021 19:05:24 -0700 Subject: [PATCH 1/4] remove arbitrary 600 pixel limit on quick input widget use 75% of available width rather than minimum of 62% of available width or 600 pixel max width --- src/vs/platform/quickinput/browser/quickInputController.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/vs/platform/quickinput/browser/quickInputController.ts b/src/vs/platform/quickinput/browser/quickInputController.ts index 93ca64256bea8..70778265398b0 100644 --- a/src/vs/platform/quickinput/browser/quickInputController.ts +++ b/src/vs/platform/quickinput/browser/quickInputController.ts @@ -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; @@ -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 = this.dimension!.width * 0.75; style.width = width + 'px'; style.marginLeft = '-' + (width / 2) + 'px'; From 70f1cbda44d23d10112ff480f049a8db99e665e7 Mon Sep 17 00:00:00 2001 From: Derek Scherger Date: Tue, 2 Mar 2021 23:02:07 -0700 Subject: [PATCH 2/4] add maximumWidth and relativeWidth quickOpen settings These preserve the existing behaviour and width of the quickOpen widget but allow for customization in situations where long filenames and paths can cause problems selecting the correct file to open. --- src/vs/platform/quickinput/browser/quickInput.ts | 2 ++ .../quickinput/browser/quickInputController.ts | 2 +- .../quickinput/browser/quickInputService.ts | 2 ++ .../quickinput/test/browser/quickinput.test.ts | 2 ++ src/vs/workbench/browser/workbench.contribution.ts | 14 ++++++++++++++ .../quickinput/browser/quickInputService.ts | 2 ++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/vs/platform/quickinput/browser/quickInput.ts b/src/vs/platform/quickinput/browser/quickInput.ts index 6d7096e85ea10..31f3bb972c85c 100644 --- a/src/vs/platform/quickinput/browser/quickInput.ts +++ b/src/vs/platform/quickinput/browser/quickInput.ts @@ -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; diff --git a/src/vs/platform/quickinput/browser/quickInputController.ts b/src/vs/platform/quickinput/browser/quickInputController.ts index 70778265398b0..c1f5e8e396f06 100644 --- a/src/vs/platform/quickinput/browser/quickInputController.ts +++ b/src/vs/platform/quickinput/browser/quickInputController.ts @@ -729,7 +729,7 @@ export class QuickInputController extends Disposable { this.ui.container.style.top = `${this.titleBarOffset}px`; const style = this.ui.container.style; - const width = this.dimension!.width * 0.75; + const width = Math.min(this.dimension!.width * this.options.relativeWidth(), this.options.maximumWidth()); style.width = width + 'px'; style.marginLeft = '-' + (width / 2) + 'px'; diff --git a/src/vs/platform/quickinput/browser/quickInputService.ts b/src/vs/platform/quickinput/browser/quickInputService.ts index ccdb696556365..cb58b822aa705 100644 --- a/src/vs/platform/quickinput/browser/quickInputService.ts +++ b/src/vs/platform/quickinput/browser/quickInputService.ts @@ -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) => { diff --git a/src/vs/platform/quickinput/test/browser/quickinput.test.ts b/src/vs/platform/quickinput/test/browser/quickinput.test.ts index f33759e20e3eb..2b04e0562f5c6 100644 --- a/src/vs/platform/quickinput/test/browser/quickinput.test.ts +++ b/src/vs/platform/quickinput/test/browser/quickinput.test.ts @@ -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; }, diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index 4d2143e0ecf97..dca5d499e7d32 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -490,6 +490,20 @@ const registry = Registry.as(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."), diff --git a/src/vs/workbench/services/quickinput/browser/quickInputService.ts b/src/vs/workbench/services/quickinput/browser/quickInputService.ts index 9be0b08b99691..3b5500ccbbda0 100644 --- a/src/vs/workbench/services/quickinput/browser/quickInputService.ts +++ b/src/vs/workbench/services/quickinput/browser/quickInputService.ts @@ -40,6 +40,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, }); } From b211f035554fc0c73f16160b854d6409bdf07e0d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:47:10 -0800 Subject: [PATCH 3/4] Tweak min/max values --- src/vs/workbench/browser/workbench.contribution.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index dca5d499e7d32..59643db63dde6 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -501,8 +501,8 @@ const registry = Registry.as(ConfigurationExtensions.Con '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 + 'minimum': 0.5, + 'maximum': 0.9 }, 'workbench.settings.openDefaultSettings': { 'type': 'boolean', From a05a95573338f83090821c549146fc330f093500 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:49:59 -0800 Subject: [PATCH 4/4] Make experimental and clamp numbers --- src/vs/workbench/browser/workbench.contribution.ts | 4 ++-- .../services/quickinput/browser/quickInputService.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index 59643db63dde6..b544c7e227e3e 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -490,14 +490,14 @@ const registry = Registry.as(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': { + '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 }, - 'workbench.quickOpen.relativeWidth': { + '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, diff --git a/src/vs/workbench/services/quickinput/browser/quickInputService.ts b/src/vs/workbench/services/quickinput/browser/quickInputService.ts index 3b5500ccbbda0..3c39c99e530fe 100644 --- a/src/vs/workbench/services/quickinput/browser/quickInputService.ts +++ b/src/vs/workbench/services/quickinput/browser/quickInputService.ts @@ -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 { @@ -40,8 +41,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'), + 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, }); }