Skip to content

Commit aac461a

Browse files
author
Eric Amodio
committed
Improves behavior for microsoft#114945
1 parent 851a849 commit aac461a

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

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

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,12 @@ class SCMInputWidget extends Disposable {
16121612
this.editorContainer = append(this.element, $('.scm-editor-container'));
16131613
this.placeholderTextContainer = append(this.editorContainer, $('.scm-editor-placeholder'));
16141614

1615+
const fontFamily = this.getInputEditorFontFamily();
1616+
const fontSize = this.getInputEditorFontSize();
1617+
const lineHeight = this.computeLineHeight(fontSize);
1618+
1619+
this.setPlaceholderFontStyles(fontFamily, fontSize, lineHeight);
1620+
16151621
const contextKeyService2 = contextKeyService.createScoped(this.element);
16161622
this.repositoryContextKey = contextKeyService2.createKey('scmRepository', undefined);
16171623

@@ -1620,9 +1626,9 @@ class SCMInputWidget extends Disposable {
16201626
lineDecorationsWidth: 4,
16211627
dragAndDrop: false,
16221628
cursorWidth: 1,
1623-
fontSize: 13,
1624-
lineHeight: 20,
1625-
fontFamily: this.getInputEditorFontFamily(),
1629+
fontSize: fontSize,
1630+
lineHeight: lineHeight,
1631+
fontFamily: fontFamily,
16261632
wrappingStrategy: 'advanced',
16271633
wrappingIndent: 'none',
16281634
padding: { top: 3, bottom: 3 },
@@ -1676,11 +1682,20 @@ class SCMInputWidget extends Disposable {
16761682
lastLineKey.set(viewPosition.lineNumber === lastLineNumber && viewPosition.column === lastLineCol);
16771683
}));
16781684

1679-
const onInputFontFamilyChanged = Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.inputFontFamily'));
1680-
this._register(onInputFontFamilyChanged(() => this.inputEditor.updateOptions({ fontFamily: this.getInputEditorFontFamily() })));
1685+
const onInputFontFamilyChanged = Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.inputFontFamily') || e.affectsConfiguration('scm.inputFontSize'));
1686+
this._register(onInputFontFamilyChanged(() => {
1687+
const fontFamily = this.getInputEditorFontFamily();
1688+
const fontSize = this.getInputEditorFontSize();
1689+
const lineHeight = this.computeLineHeight(fontSize);
16811690

1682-
const onInputFontSizeChanged = Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.inputFontSize'));
1683-
this._register(onInputFontSizeChanged(() => this.inputEditor.updateOptions({ fontSize: this.getInputEditorFontSize() })));
1691+
this.inputEditor.updateOptions({
1692+
fontFamily: fontFamily,
1693+
fontSize: fontSize,
1694+
lineHeight: lineHeight,
1695+
});
1696+
1697+
this.setPlaceholderFontStyles(fontFamily, fontSize, lineHeight);
1698+
}));
16841699

16851700
this.onDidChangeContentHeight = Event.signal(Event.filter(this.inputEditor.onDidContentSizeChange, e => e.contentHeightChanged));
16861701
}
@@ -1768,6 +1783,16 @@ class SCMInputWidget extends Disposable {
17681783
return this.configurationService.getValue<number>('scm.inputFontSize');
17691784
}
17701785

1786+
private computeLineHeight(fontSize: number): number {
1787+
return Math.round(fontSize * 1.5);
1788+
}
1789+
1790+
private setPlaceholderFontStyles(fontFamily: string, fontSize: number, lineHeight: number): void {
1791+
this.placeholderTextContainer.style.fontFamily = fontFamily;
1792+
this.placeholderTextContainer.style.fontSize = `${fontSize}px`;
1793+
this.placeholderTextContainer.style.lineHeight = `${lineHeight}px`;
1794+
}
1795+
17711796
clearValidation(): void {
17721797
this.validationDisposable.dispose();
17731798
}

0 commit comments

Comments
 (0)