Skip to content

Commit

Permalink
Closes #3306 adds inline blame font controls
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed May 18, 2024
1 parent ab8e2fc commit c61b89b
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

- Adds a _Copy as Markdown_ context menu command to autolinks in the _Autolinked Issues and Pull Requests_ section in the _Search & Compare_ view
- Adds a _Connect Remote Integration_ command to the _Autolinked Issues and Pull Requests_ section in the _Search & Compare_ view
- 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)
- Adds `gitlens.blame.fontStyle` settings to specify the font style of the _File Blame_ annotations

### Changed

Expand Down
41 changes: 38 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,34 @@
"scope": "window",
"order": 31
},
"gitlens.currentLine.fontFamily": {
"type": "string",
"default": "",
"markdownDescription": "Specifies the font family of the inline blame annotation",
"scope": "window",
"order": 33
},
"gitlens.currentLine.fontSize": {
"type": "number",
"default": 0,
"markdownDescription": "Specifies the font size of the inline blame annotation",
"scope": "window",
"order": 34
},
"gitlens.currentLine.fontStyle": {
"type": "string",
"default": "normal",
"markdownDescription": "Specifies the font style of the inline blame annotation",
"scope": "window",
"order": 35
},
"gitlens.currentLine.fontWeight": {
"type": "string",
"default": "normal",
"markdownDescription": "Specifies the font weight of the inline blame annotation",
"scope": "window",
"order": 36
},
"gitlens.currentLine.scrollable": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -2398,21 +2426,28 @@
"default": "",
"markdownDescription": "Specifies the font family of the file blame annotations",
"scope": "window",
"order": 21
"order": 22
},
"gitlens.blame.fontSize": {
"type": "number",
"default": 0,
"markdownDescription": "Specifies the font size of the file blame annotations",
"scope": "window",
"order": 22
"order": 23
},
"gitlens.blame.fontStyle": {
"type": "string",
"default": "normal",
"markdownDescription": "Specifies the font style of the file blame annotations",
"scope": "window",
"order": 24
},
"gitlens.blame.fontWeight": {
"type": "string",
"default": "normal",
"markdownDescription": "Specifies the font weight of the file blame annotations",
"scope": "window",
"order": 22
"order": 25
},
"gitlens.blame.heatmap.enabled": {
"type": "boolean",
Expand Down
13 changes: 8 additions & 5 deletions src/annotations/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ export function getGutterRenderOptions(
borderWidth: borderWidth,
color: new ThemeColor('gitlens.gutterForegroundColor' satisfies Colors),
fontWeight: fontOptions.weight ?? 'normal',
fontStyle: fontOptions.weight ?? 'normal',
fontStyle: fontOptions.style ?? 'normal',
height: '100%',
margin: '0 26px -1px 0',
textDecoration: `${separateLines ? 'overline solid rgba(0, 0, 0, .2)' : 'none'};box-sizing: border-box${
avatars ? ';padding: 0 0 0 18px' : ''
}${fontOptions.family ? `;font-family: ${fontOptions.family}` : ''}${
fontOptions.size ? `;font-size: ${fontOptions.size}px` : ''
}`,
};`,
width: width,
uncommittedColor: new ThemeColor('gitlens.gutterUncommittedForegroundColor' satisfies Colors),
};
Expand All @@ -234,6 +234,7 @@ export function getInlineDecoration(
// editorLine: number,
format: string,
formatOptions?: CommitFormatOptions,
fontOptions?: BlameFontOptions,
scrollable: boolean = true,
): Partial<DecorationOptions> {
// TODO: Enable this once there is better caching
Expand All @@ -254,10 +255,12 @@ export function getInlineDecoration(
backgroundColor: new ThemeColor('gitlens.trailingLineBackgroundColor' satisfies Colors),
color: new ThemeColor('gitlens.trailingLineForegroundColor' satisfies Colors),
contentText: pad(message.replace(/ /g, GlyphChars.Space), 1, 1),
fontWeight: 'normal',
fontStyle: 'normal',
fontWeight: fontOptions?.weight ?? 'normal',
fontStyle: fontOptions?.style ?? 'normal',
// Pull the decoration out of the document flow if we want to be scrollable
textDecoration: `none;${scrollable ? '' : ' position: absolute;'}`,
textDecoration: `none${scrollable ? '' : ';position: absolute'}${
fontOptions?.family ? `;font-family: ${fontOptions.family}` : ''
}${fontOptions?.size ? `;font-size: ${fontOptions.size}px` : ''};`,
},
},
};
Expand Down
2 changes: 2 additions & 0 deletions src/annotations/gutterBlameAnnotationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const maxSmallIntegerV8 = 2 ** 30 - 1; // Max number that can be stored in V8's
export interface BlameFontOptions {
family: string;
size: number;
style: string;
weight: string;
}

Expand Down Expand Up @@ -77,6 +78,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
const fontOptions: BlameFontOptions = {
family: configuration.get('blame.fontFamily'),
size: configuration.get('blame.fontSize'),
style: configuration.get('blame.fontStyle'),
weight: configuration.get('blame.fontWeight'),
};

Expand Down
9 changes: 9 additions & 0 deletions src/annotations/lineAnnotationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getSettledValue } from '../system/promise';
import { isTextEditor } from '../system/utils';
import type { LinesChangeEvent, LineState } from '../trackers/lineTracker';
import { getInlineDecoration } from './annotations';
import type { BlameFontOptions } from './gutterBlameAnnotationProvider';

const annotationDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
after: {
Expand Down Expand Up @@ -300,6 +301,13 @@ export class LineAnnotationController implements Disposable {
prs: Map<string, MaybePausedResult<PullRequest | undefined>> | undefined,
timeout?: number,
) {
const fontOptions: BlameFontOptions = {
family: cfg.fontFamily,
size: cfg.fontSize,
style: cfg.fontStyle,
weight: cfg.fontWeight,
};

const decorations = [];

for (const [l, state] of lines) {
Expand All @@ -319,6 +327,7 @@ export class LineAnnotationController implements Disposable {
pullRequest: pr?.value,
pullRequestPendingMessage: `PR ${GlyphChars.Ellipsis}`,
},
fontOptions,
cfg.scrollable,
) as DecorationOptions;
decoration.range = editor.document.validateRange(new Range(l, maxSmallIntegerV8, l, maxSmallIntegerV8));
Expand Down
7 changes: 6 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface Config {
readonly dateFormat: DateTimeFormat | (string & object) | null;
readonly fontFamily: string;
readonly fontSize: number;
readonly fontStyle: string;
readonly fontWeight: string;
readonly format: string;
readonly heatmap: {
Expand Down Expand Up @@ -60,12 +61,16 @@ export interface Config {
readonly currentLine: {
readonly dateFormat: string | null;
/*readonly*/ enabled: boolean;
readonly fontFamily: string;
readonly fontSize: number;
readonly fontStyle: string;
readonly fontWeight: string;
readonly format: string;
readonly uncommittedChangesFormat: string | null;
readonly pullRequests: {
readonly enabled: boolean;
};
readonly scrollable: boolean;
readonly uncommittedChangesFormat: string | null;
};
readonly debug: boolean;
readonly deepLinks: {
Expand Down

0 comments on commit c61b89b

Please sign in to comment.