Skip to content

Commit d696b40

Browse files
authored
SCM - 💄 code cleanup and bug fix (microsoft#201068)
1 parent 3fdb0d4 commit d696b40

File tree

1 file changed

+15
-33
lines changed

1 file changed

+15
-33
lines changed

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,11 +2263,19 @@ class SCMInputWidget {
22632263
}
22642264

22652265
getContentHeight(): number {
2266-
const inputEditorMinHeight = this.getInputEditorMinHeight();
2267-
const editorContentHeight = Math.max(this.inputEditor.getContentHeight(), inputEditorMinHeight);
2268-
const editorContextHeightMax = this.getInputEditorMaxHeight();
2266+
const fontSize = this.getInputEditorFontSize();
2267+
const lineHeight = this.computeLineHeight(fontSize);
2268+
const { top, bottom } = this.inputEditor.getOption(EditorOption.padding);
22692269

2270-
return Math.min(editorContentHeight, editorContextHeightMax);
2270+
const inputMinLinesConfig = this.configurationService.getValue('scm.inputMinLines');
2271+
const inputMinLines = typeof inputMinLinesConfig === 'number' ? clamp(inputMinLinesConfig, 1, 50) : 1;
2272+
const editorMinHeight = inputMinLines * lineHeight + top + bottom;
2273+
2274+
const inputMaxLinesConfig = this.configurationService.getValue('scm.inputMaxLines');
2275+
const inputMaxLines = typeof inputMaxLinesConfig === 'number' ? clamp(inputMaxLinesConfig, 1, 50) : 10;
2276+
const editorMaxHeight = inputMaxLines * lineHeight + top + bottom;
2277+
2278+
return clamp(this.inputEditor.getContentHeight(), editorMinHeight, editorMaxHeight);
22712279
}
22722280

22732281
layout(): void {
@@ -2404,34 +2412,6 @@ class SCMInputWidget {
24042412
return this.configurationService.getValue<number>('scm.inputFontSize');
24052413
}
24062414

2407-
private getInputEditorMaxLines(): number {
2408-
const inputMaxLines = this.configurationService.getValue('scm.inputMaxLines');
2409-
return typeof inputMaxLines === 'number' ? clamp(inputMaxLines, 1, 50) : 10;
2410-
}
2411-
2412-
private getInputEditorMinLines(): number {
2413-
const inputMinLines = this.configurationService.getValue('scm.inputMinLines');
2414-
return typeof inputMinLines === 'number' ? clamp(inputMinLines, 1, 50) : 1;
2415-
}
2416-
2417-
private getInputEditorMaxHeight(): number {
2418-
const maxLines = this.getInputEditorMaxLines();
2419-
const fontSize = this.getInputEditorFontSize();
2420-
const lineHeight = this.computeLineHeight(fontSize);
2421-
const { top, bottom } = this.inputEditor.getOption(EditorOption.padding);
2422-
2423-
return maxLines * lineHeight + top + bottom;
2424-
}
2425-
2426-
private getInputEditorMinHeight(): number {
2427-
const minLines = this.getInputEditorMinLines();
2428-
const fontSize = this.getInputEditorFontSize();
2429-
const lineHeight = this.computeLineHeight(fontSize);
2430-
const { top, bottom } = this.inputEditor.getOption(EditorOption.padding);
2431-
2432-
return minLines * lineHeight + top + bottom;
2433-
}
2434-
24352415
private getToolbarWidth(): number {
24362416
const showInputActionButton = this.configurationService.getValue<boolean>('scm.showInputActionButton');
24372417
if (!this.toolbar || !showInputActionButton || this.toolbar?.isEmpty() === true) {
@@ -2667,7 +2647,9 @@ export class SCMViewPane extends ViewPane {
26672647
e.affectsConfiguration('scm.showActionButton') ||
26682648
e.affectsConfiguration('scm.alwaysShowRepositories') ||
26692649
e.affectsConfiguration('scm.showIncomingChanges') ||
2670-
e.affectsConfiguration('scm.showOutgoingChanges')) {
2650+
e.affectsConfiguration('scm.showOutgoingChanges') ||
2651+
e.affectsConfiguration('scm.inputMinLines') ||
2652+
e.affectsConfiguration('scm.inputMaxLines')) {
26712653
this._showActionButton = this.configurationService.getValue<boolean>('scm.showActionButton');
26722654
this._alwaysShowRepositories = this.configurationService.getValue<boolean>('scm.alwaysShowRepositories');
26732655
this._showIncomingChanges = this.configurationService.getValue<ShowChangesSetting>('scm.showIncomingChanges');

0 commit comments

Comments
 (0)