diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index f55160546a7..3d089ec8f45 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -2088,9 +2088,6 @@ class SCMInputWidget { this.actionBar.push(action, { icon: true, label: false }); } - const showInputActionButton = this.configurationService.getValue('scm.showInputActionButton') === true; - this.actionBar.domNode.classList.toggle('hidden', !showInputActionButton || this.actionBar.isEmpty()); - this.layout(); }; @@ -2330,7 +2327,7 @@ class SCMInputWidget { layout(): void { const editorHeight = this.getContentHeight(); - const toolbarWidth = this.toolbarContainer.clientWidth; + const toolbarWidth = this.getToolbarWidth(); const dimension = new Dimension(this.element.clientWidth - toolbarWidth, editorHeight); if (dimension.width < 0) { @@ -2343,6 +2340,9 @@ class SCMInputWidget { this.placeholderTextContainer.style.width = `${dimension.width}px`; this.renderValidation(); + this.actionBar.domNode.classList.toggle('hidden', this.actionBar.isEmpty()); + this.toolbarContainer.classList.toggle('hidden', this.configurationService.getValue('scm.showInputActionButton') === false); + if (this.shouldFocusAfterLayout) { this.shouldFocusAfterLayout = false; this.focus(); @@ -2473,6 +2473,17 @@ class SCMInputWidget { return maxLines * lineHeight + top + bottom; } + private getToolbarWidth(): number { + const showInputActionButton = this.configurationService.getValue('scm.showInputActionButton'); + const actionCount = this.toolbarContextKeyService.getContextKeyValue(SCMInputContextKeys.ActionCount.key) ?? 0; + + if (!showInputActionButton || (this.actionBar.isEmpty() && actionCount === 0)) { + return 0; + } + + return 26; /* 22px action + 4px margin */ + } + private computeLineHeight(fontSize: number): number { return Math.round(fontSize * 1.5); }