From 3fdb0d4e83a68fa9e2c9f7c39324975ffa11e521 Mon Sep 17 00:00:00 2001 From: MaxBR97 <103818169+MaxBR97@users.noreply.github.com> Date: Sat, 16 Dec 2023 17:57:50 +0200 Subject: [PATCH] Added scm.inputMinLines configuration (#200551) * added scm.inputMinLines * Update scm.contribution.ts Changed default to 1 per PR reject --- .../contrib/scm/browser/scm.contribution.ts | 7 +++++++ .../contrib/scm/browser/scmViewPane.ts | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/scm/browser/scm.contribution.ts b/src/vs/workbench/contrib/scm/browser/scm.contribution.ts index a927038333b..58a66dda8a0 100644 --- a/src/vs/workbench/contrib/scm/browser/scm.contribution.ts +++ b/src/vs/workbench/contrib/scm/browser/scm.contribution.ts @@ -262,6 +262,13 @@ Registry.as(ConfigurationExtensions.Configuration).regis maximum: 50, default: 10 }, + 'scm.inputMinLines': { + type: 'number', + markdownDescription: localize('inputMinLines', "Controls the minimum number of lines that the input will auto-grow from."), + minimum: 1, + maximum: 50, + default: 1 + }, 'scm.alwaysShowRepositories': { type: 'boolean', markdownDescription: localize('alwaysShowRepository', "Controls whether repositories should always be visible in the Source Control view."), diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index 6228a4d4e4c..1280fc3ee9e 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -2263,7 +2263,8 @@ class SCMInputWidget { } getContentHeight(): number { - const editorContentHeight = this.inputEditor.getContentHeight(); + const inputEditorMinHeight = this.getInputEditorMinHeight(); + const editorContentHeight = Math.max(this.inputEditor.getContentHeight(), inputEditorMinHeight); const editorContextHeightMax = this.getInputEditorMaxHeight(); return Math.min(editorContentHeight, editorContextHeightMax); @@ -2408,6 +2409,11 @@ class SCMInputWidget { return typeof inputMaxLines === 'number' ? clamp(inputMaxLines, 1, 50) : 10; } + private getInputEditorMinLines(): number { + const inputMinLines = this.configurationService.getValue('scm.inputMinLines'); + return typeof inputMinLines === 'number' ? clamp(inputMinLines, 1, 50) : 1; + } + private getInputEditorMaxHeight(): number { const maxLines = this.getInputEditorMaxLines(); const fontSize = this.getInputEditorFontSize(); @@ -2417,6 +2423,15 @@ class SCMInputWidget { return maxLines * lineHeight + top + bottom; } + private getInputEditorMinHeight(): number { + const minLines = this.getInputEditorMinLines(); + const fontSize = this.getInputEditorFontSize(); + const lineHeight = this.computeLineHeight(fontSize); + const { top, bottom } = this.inputEditor.getOption(EditorOption.padding); + + return minLines * lineHeight + top + bottom; + } + private getToolbarWidth(): number { const showInputActionButton = this.configurationService.getValue('scm.showInputActionButton'); if (!this.toolbar || !showInputActionButton || this.toolbar?.isEmpty() === true) {