Skip to content

Commit 09f9177

Browse files
authored
Chat - add fontSize and fontFamily settings (microsoft#263299)
* Chat - add fontSize and fontFamily settings * Chat - add fontSize and fontFamily settings
1 parent 9e71c8e commit 09f9177

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

build/lib/stylelint/vscode-known-variables.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
"--vscode-chat-avatarForeground",
5555
"--vscode-chat-checkpointSeparator",
5656
"--vscode-chat-editedFileForeground",
57+
"--vscode-chat-font-family",
58+
"--vscode-chat-font-size",
5759
"--vscode-chat-linesAddedForeground",
5860
"--vscode-chat-linesRemovedForeground",
5961
"--vscode-chat-requestBackground",
@@ -965,4 +967,4 @@
965967
"--animation-opacity",
966968
"--chat-setup-dialog-glow-angle"
967969
]
968-
}
970+
}

src/vs/workbench/contrib/chat/browser/chat.contribution.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ configurationRegistry.registerConfiguration({
127127
title: nls.localize('interactiveSessionConfigurationTitle', "Chat"),
128128
type: 'object',
129129
properties: {
130+
'chat.fontSize': {
131+
type: 'number',
132+
description: nls.localize('chat.fontSize', "Controls the font size in pixels in chat messages."),
133+
default: 13,
134+
minimum: 13,
135+
maximum: 100
136+
},
137+
'chat.fontFamily': {
138+
type: 'string',
139+
description: nls.localize('chat.fontFamily', "Controls the font family in chat messages."),
140+
default: 'default'
141+
},
130142
'chat.editor.fontSize': {
131143
type: 'number',
132144
description: nls.localize('interactiveSession.editor.fontSize', "Controls the font size in pixels in chat codeblocks."),

src/vs/workbench/contrib/chat/browser/chatWidget.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { IInstantiationService } from '../../../../platform/instantiation/common
3535
import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js';
3636
import { WorkbenchObjectTree } from '../../../../platform/list/browser/listService.js';
3737
import { ILogService } from '../../../../platform/log/common/log.js';
38-
import { bindContextKey } from '../../../../platform/observable/common/platformObservableUtils.js';
38+
import { bindContextKey, observableConfigValue } from '../../../../platform/observable/common/platformObservableUtils.js';
3939
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js';
4040
import { buttonSecondaryBackground, buttonSecondaryForeground, buttonSecondaryHoverBackground } from '../../../../platform/theme/common/colorRegistry.js';
4141
import { asCssVariable } from '../../../../platform/theme/common/colorUtils.js';
@@ -604,6 +604,17 @@ export class ChatWidget extends Disposable implements IChatWidget {
604604
this.scrollToEnd();
605605
}));
606606

607+
const chatFontSize = observableConfigValue<number>('chat.fontSize', 13, this.configurationService);
608+
const chatFontFamily = observableConfigValue<string>('chat.fontFamily', 'default', this.configurationService);
609+
610+
this._register(autorun(r => {
611+
const fontSize = chatFontSize.read(r);
612+
const fontFamily = chatFontFamily.read(r);
613+
614+
this.container.style.setProperty('--vscode-chat-font-family', fontFamily === 'default' ? null : fontFamily);
615+
this.container.style.setProperty('--vscode-chat-font-size', `${fontSize}px`);
616+
}));
617+
607618
this._register(this.editorOptions.onDidChange(() => this.onDidStyleChange()));
608619
this.onDidStyleChange();
609620

src/vs/workbench/contrib/chat/browser/media/chat.css

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,30 +334,33 @@
334334
}
335335

336336
.interactive-item-container .value .rendered-markdown h1 {
337-
font-size: 20px;
337+
font-size: calc(var(--vscode-chat-font-size, 13px) * 1.54); /* 20px when base is 13px */
338338
font-weight: 600;
339339
margin: 16px 0 8px 0;
340+
font-family: var(--vscode-chat-font-family, inherit);
340341

341342
}
342343

343344
.interactive-item-container .value .rendered-markdown h2 {
344-
font-size: 16px;
345+
font-size: calc(var(--vscode-chat-font-size, 13px) * 1.23); /* 16px when base is 13px */
345346
font-weight: 600;
346347
margin: 16px 0 8px 0;
348+
font-family: var(--vscode-chat-font-family, inherit);
347349
}
348350

349351
.interactive-item-container .value .rendered-markdown h3 {
350-
font-size: 14px;
352+
font-size: calc(var(--vscode-chat-font-size, 13px) * 1.08); /* 14px when base is 13px */
351353
font-weight: 600;
352354
margin: 16px 0 8px 0;
355+
font-family: var(--vscode-chat-font-family, inherit);
353356
}
354357

355358
.interactive-item-container.editing-session .value .rendered-markdown p:has(+ [data-code] > .chat-codeblock-pill-widget) {
356359
margin-bottom: 8px;
357360
}
358361

359362
.interactive-item-container.editing-session .value .rendered-markdown h3 {
360-
font-size: 13px;
363+
font-size: var(--vscode-chat-font-size, 13px);
361364
margin: 0 0 8px 0;
362365
font-weight: unset;
363366
}
@@ -414,7 +417,10 @@
414417
}
415418

416419
.interactive-item-container .value .rendered-markdown {
420+
letter-spacing: 0.01em;
417421
line-height: 1.5em;
422+
font-size: var(--vscode-chat-font-size, 13px);
423+
font-family: var(--vscode-chat-font-family, inherit);
418424
}
419425

420426
.interactive-item-container .value > .rendered-markdown p {
@@ -589,7 +595,7 @@ have to be updated for changes to the rules above, or to support more deeply nes
589595
.monaco-tokenized-source,
590596
code {
591597
font-family: var(--monaco-monospace-font);
592-
font-size: 12px;
598+
font-size: calc(var(--vscode-chat-font-size, 13px) * 0.92); /* 12px when base is 13px */
593599
color: var(--vscode-textPreformat-foreground);
594600
background-color: var(--vscode-textPreformat-background);
595601
padding: 1px 3px;

0 commit comments

Comments
 (0)