Skip to content

Commit c61b89b

Browse files
committed
Closes #3306 adds inline blame font controls
1 parent ab8e2fc commit c61b89b

File tree

6 files changed

+65
-9
lines changed

6 files changed

+65
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1010

1111
- Adds a _Copy as Markdown_ context menu command to autolinks in the _Autolinked Issues and Pull Requests_ section in the _Search & Compare_ view
1212
- Adds a _Connect Remote Integration_ command to the _Autolinked Issues and Pull Requests_ section in the _Search & Compare_ view
13+
- Adds `gitlens.currentLine.fontFamily`, `gitlens.currentLine.fontSize`, `gitlens.currentLine.fontStyle`, `gitlens.currentLine.fontWeight` settings to specify the font (family, size, style, and weight respectively) of the _Inline Blame_ annotation — closes [#3306](https://github.com/gitkraken/vscode-gitlens/issues/3306)
14+
- Adds `gitlens.blame.fontStyle` settings to specify the font style of the _File Blame_ annotations
1315

1416
### Changed
1517

package.json

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,34 @@
9999
"scope": "window",
100100
"order": 31
101101
},
102+
"gitlens.currentLine.fontFamily": {
103+
"type": "string",
104+
"default": "",
105+
"markdownDescription": "Specifies the font family of the inline blame annotation",
106+
"scope": "window",
107+
"order": 33
108+
},
109+
"gitlens.currentLine.fontSize": {
110+
"type": "number",
111+
"default": 0,
112+
"markdownDescription": "Specifies the font size of the inline blame annotation",
113+
"scope": "window",
114+
"order": 34
115+
},
116+
"gitlens.currentLine.fontStyle": {
117+
"type": "string",
118+
"default": "normal",
119+
"markdownDescription": "Specifies the font style of the inline blame annotation",
120+
"scope": "window",
121+
"order": 35
122+
},
123+
"gitlens.currentLine.fontWeight": {
124+
"type": "string",
125+
"default": "normal",
126+
"markdownDescription": "Specifies the font weight of the inline blame annotation",
127+
"scope": "window",
128+
"order": 36
129+
},
102130
"gitlens.currentLine.scrollable": {
103131
"type": "boolean",
104132
"default": true,
@@ -2398,21 +2426,28 @@
23982426
"default": "",
23992427
"markdownDescription": "Specifies the font family of the file blame annotations",
24002428
"scope": "window",
2401-
"order": 21
2429+
"order": 22
24022430
},
24032431
"gitlens.blame.fontSize": {
24042432
"type": "number",
24052433
"default": 0,
24062434
"markdownDescription": "Specifies the font size of the file blame annotations",
24072435
"scope": "window",
2408-
"order": 22
2436+
"order": 23
2437+
},
2438+
"gitlens.blame.fontStyle": {
2439+
"type": "string",
2440+
"default": "normal",
2441+
"markdownDescription": "Specifies the font style of the file blame annotations",
2442+
"scope": "window",
2443+
"order": 24
24092444
},
24102445
"gitlens.blame.fontWeight": {
24112446
"type": "string",
24122447
"default": "normal",
24132448
"markdownDescription": "Specifies the font weight of the file blame annotations",
24142449
"scope": "window",
2415-
"order": 22
2450+
"order": 25
24162451
},
24172452
"gitlens.blame.heatmap.enabled": {
24182453
"type": "boolean",

src/annotations/annotations.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ export function getGutterRenderOptions(
215215
borderWidth: borderWidth,
216216
color: new ThemeColor('gitlens.gutterForegroundColor' satisfies Colors),
217217
fontWeight: fontOptions.weight ?? 'normal',
218-
fontStyle: fontOptions.weight ?? 'normal',
218+
fontStyle: fontOptions.style ?? 'normal',
219219
height: '100%',
220220
margin: '0 26px -1px 0',
221221
textDecoration: `${separateLines ? 'overline solid rgba(0, 0, 0, .2)' : 'none'};box-sizing: border-box${
222222
avatars ? ';padding: 0 0 0 18px' : ''
223223
}${fontOptions.family ? `;font-family: ${fontOptions.family}` : ''}${
224224
fontOptions.size ? `;font-size: ${fontOptions.size}px` : ''
225-
}`,
225+
};`,
226226
width: width,
227227
uncommittedColor: new ThemeColor('gitlens.gutterUncommittedForegroundColor' satisfies Colors),
228228
};
@@ -234,6 +234,7 @@ export function getInlineDecoration(
234234
// editorLine: number,
235235
format: string,
236236
formatOptions?: CommitFormatOptions,
237+
fontOptions?: BlameFontOptions,
237238
scrollable: boolean = true,
238239
): Partial<DecorationOptions> {
239240
// TODO: Enable this once there is better caching
@@ -254,10 +255,12 @@ export function getInlineDecoration(
254255
backgroundColor: new ThemeColor('gitlens.trailingLineBackgroundColor' satisfies Colors),
255256
color: new ThemeColor('gitlens.trailingLineForegroundColor' satisfies Colors),
256257
contentText: pad(message.replace(/ /g, GlyphChars.Space), 1, 1),
257-
fontWeight: 'normal',
258-
fontStyle: 'normal',
258+
fontWeight: fontOptions?.weight ?? 'normal',
259+
fontStyle: fontOptions?.style ?? 'normal',
259260
// Pull the decoration out of the document flow if we want to be scrollable
260-
textDecoration: `none;${scrollable ? '' : ' position: absolute;'}`,
261+
textDecoration: `none${scrollable ? '' : ';position: absolute'}${
262+
fontOptions?.family ? `;font-family: ${fontOptions.family}` : ''
263+
}${fontOptions?.size ? `;font-size: ${fontOptions.size}px` : ''};`,
261264
},
262265
},
263266
};

src/annotations/gutterBlameAnnotationProvider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const maxSmallIntegerV8 = 2 ** 30 - 1; // Max number that can be stored in V8's
2525
export interface BlameFontOptions {
2626
family: string;
2727
size: number;
28+
style: string;
2829
weight: string;
2930
}
3031

@@ -77,6 +78,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
7778
const fontOptions: BlameFontOptions = {
7879
family: configuration.get('blame.fontFamily'),
7980
size: configuration.get('blame.fontSize'),
81+
style: configuration.get('blame.fontStyle'),
8082
weight: configuration.get('blame.fontWeight'),
8183
};
8284

src/annotations/lineAnnotationController.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { getSettledValue } from '../system/promise';
1717
import { isTextEditor } from '../system/utils';
1818
import type { LinesChangeEvent, LineState } from '../trackers/lineTracker';
1919
import { getInlineDecoration } from './annotations';
20+
import type { BlameFontOptions } from './gutterBlameAnnotationProvider';
2021

2122
const annotationDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
2223
after: {
@@ -300,6 +301,13 @@ export class LineAnnotationController implements Disposable {
300301
prs: Map<string, MaybePausedResult<PullRequest | undefined>> | undefined,
301302
timeout?: number,
302303
) {
304+
const fontOptions: BlameFontOptions = {
305+
family: cfg.fontFamily,
306+
size: cfg.fontSize,
307+
style: cfg.fontStyle,
308+
weight: cfg.fontWeight,
309+
};
310+
303311
const decorations = [];
304312

305313
for (const [l, state] of lines) {
@@ -319,6 +327,7 @@ export class LineAnnotationController implements Disposable {
319327
pullRequest: pr?.value,
320328
pullRequestPendingMessage: `PR ${GlyphChars.Ellipsis}`,
321329
},
330+
fontOptions,
322331
cfg.scrollable,
323332
) as DecorationOptions;
324333
decoration.range = editor.document.validateRange(new Range(l, maxSmallIntegerV8, l, maxSmallIntegerV8));

src/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface Config {
3232
readonly dateFormat: DateTimeFormat | (string & object) | null;
3333
readonly fontFamily: string;
3434
readonly fontSize: number;
35+
readonly fontStyle: string;
3536
readonly fontWeight: string;
3637
readonly format: string;
3738
readonly heatmap: {
@@ -60,12 +61,16 @@ export interface Config {
6061
readonly currentLine: {
6162
readonly dateFormat: string | null;
6263
/*readonly*/ enabled: boolean;
64+
readonly fontFamily: string;
65+
readonly fontSize: number;
66+
readonly fontStyle: string;
67+
readonly fontWeight: string;
6368
readonly format: string;
64-
readonly uncommittedChangesFormat: string | null;
6569
readonly pullRequests: {
6670
readonly enabled: boolean;
6771
};
6872
readonly scrollable: boolean;
73+
readonly uncommittedChangesFormat: string | null;
6974
};
7075
readonly debug: boolean;
7176
readonly deepLinks: {

0 commit comments

Comments
 (0)