Skip to content

Commit dba38fb

Browse files
committed
Fixes #459 - letter spacing breaks gutter annotation
1 parent cd3dbb3 commit dba38fb

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1818
### Fixed
1919
- Fixes [#462](https://github.com/eamodio/vscode-gitlens/issues/462) - Source Control shortcut on macOS (⌃⇧G) shouldn't be overridden
2020
- Fixes [#457](https://github.com/eamodio/vscode-gitlens/issues/457) - Displays the wrong username (You) — thanks to [PR #460](https://github.com/eamodio/vscode-gitlens/pull/460) by Zyck ([@qzyse2017](https://github.com/qzyse2017))
21+
- Fixes [#459](https://github.com/eamodio/vscode-gitlens/issues/459) - File blame annotation text overflow with letter spacing setting
2122
- Fixes issues with GitLens Welcome and the interactive settings editor with light themes
2223

2324
## [8.5.3] - 2018-07-25

src/annotations/annotations.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {
33
DecorationOptions,
44
MarkdownString,
55
ThemableDecorationRenderOptions,
6-
ThemeColor
6+
ThemeColor,
7+
workspace
78
} from 'vscode';
89
import {
910
DiffWithCommand,
@@ -272,26 +273,26 @@ export class Annotations {
272273
format: string,
273274
options: ICommitFormatOptions
274275
): IRenderOptions {
275-
// Get the width of all the tokens, assuming there there is a cap (bail if not)
276-
let width = 0;
276+
// Get the character count of all the tokens, assuming there there is a cap (bail if not)
277+
let chars = 0;
277278
for (const token of Objects.values(options.tokenOptions!)) {
278279
if (token === undefined) continue;
279280

280281
// If any token is uncapped, kick out and set no max
281282
if (token.truncateTo == null) {
282-
width = -1;
283+
chars = -1;
283284
break;
284285
}
285286

286-
width += token.truncateTo;
287+
chars += token.truncateTo;
287288
}
288289

289-
if (width >= 0) {
290-
// Add the width of the template string (without tokens)
291-
width += Strings.getWidth(Strings.interpolate(format, undefined));
292-
// If we have some width, add a bit of padding
293-
if (width > 0) {
294-
width += 3;
290+
if (chars >= 0) {
291+
// Add the chars of the template string (without tokens)
292+
chars += Strings.getWidth(Strings.interpolate(format, undefined));
293+
// If we have chars, add a bit of padding
294+
if (chars > 0) {
295+
chars += 3;
295296
}
296297
}
297298

@@ -302,6 +303,17 @@ export class Annotations {
302303
borderWidth = heatmap.location === 'left' ? '0 0 0 2px' : '0 2px 0 0';
303304
}
304305

306+
let width;
307+
if (chars >= 0) {
308+
const spacing = workspace.getConfiguration('editor').get<number>('letterSpacing');
309+
if (spacing != null && spacing !== 0) {
310+
width = `calc(${chars}ch + ${Math.round(chars * spacing)}px)`;
311+
}
312+
else {
313+
width = `${chars}ch`;
314+
}
315+
}
316+
305317
return {
306318
backgroundColor: new ThemeColor('gitlens.gutterBackgroundColor'),
307319
borderStyle: borderStyle,
@@ -310,9 +322,9 @@ export class Annotations {
310322
fontWeight: 'normal',
311323
fontStyle: 'normal',
312324
height: '100%',
313-
margin: '0 26px -1px 0',
325+
margin: `0 26px -1px 0`,
314326
textDecoration: separateLines ? 'overline solid rgba(0, 0, 0, .2)' : 'none',
315-
width: width >= 0 ? `${width}ch` : undefined,
327+
width: width,
316328
uncommittedColor: new ThemeColor('gitlens.gutterUncommittedForegroundColor')
317329
} as IRenderOptions;
318330
}

0 commit comments

Comments
 (0)