Skip to content

Commit 30854ac

Browse files
committed
Fix unindented error pretty-printing
1 parent 52c355c commit 30854ac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ function highlight(text, line, count) {
8888

8989
function outdent(str, prefix='', width=80) {
9090
str = str.replace(/(^\n+|\n+$)/g, '').replace(/\t/, ' ');
91-
let indents = str.match(/^[ -]+/gm);
92-
let minLength = indents.reduce( (indent, value) => Math.min(indent, value.length), indents[0].length);
91+
let indents = str.match(/^[ -]+/gm) || [];
92+
let minLength = indents.reduce( (indent, value) => Math.min(indent, value.length), indents[0] ? indents[0].length : 0);
9393
str = str.replace(/^[ -]+/gm, str => prefix+str.substring(minLength));
9494
str = str.replace(/^.*$/gm, str => str.substring(0, width));
9595
return str;

0 commit comments

Comments
 (0)