Skip to content

Commit 9e9642f

Browse files
author
Vadim Demedes
committed
adjust code excerpt line trimming
1 parent 2fa8da9 commit 9e9642f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/code-excerpt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = (file, line, options) => {
1919

2020
const lines = excerpt.map(item => ({
2121
line: item.line,
22-
value: truncate(item.value, maxWidth - String(line).length - 1)
22+
value: truncate(item.value, maxWidth - String(line).length - 5)
2323
}));
2424

2525
const joinedLines = lines.map(line => line.value).join('\n');

test/code-excerpt.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ test('truncate lines', t => {
3333

3434
const excerpt = codeExcerpt(path, 2, {maxWidth: 14});
3535
const expected = [
36-
` ${chalk.grey('1:')} function a(…`,
37-
chalk.bgRed(` 2: alert(); `),
38-
` ${chalk.grey('3:')} } `
36+
` ${chalk.grey('1:')} functio…`,
37+
chalk.bgRed(` 2: alert`),
38+
` ${chalk.grey('3:')} } `
3939
].join('\n');
4040

4141
t.is(excerpt, expected);

0 commit comments

Comments
 (0)