Skip to content

Commit 6f3a1d0

Browse files
authored
repl: catch \v and \r in new-line detection
1 parent e70bd47 commit 6f3a1d0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/internal/repl/utils.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
436436

437437
// Line breaks are very rare and probably only occur in case of error
438438
// messages with line breaks.
439-
const lineBreakPos = StringPrototypeIndexOf(inspected, '\n');
440-
if (lineBreakPos !== -1) {
441-
inspected = `${StringPrototypeSlice(inspected, 0, lineBreakPos)}`;
439+
const lineBreakMatch = RegExpPrototypeExec(/[\r\n\v]/, inspected);
440+
if (lineBreakMatch !== null) {
441+
inspected = `${StringPrototypeSlice(inspected, 0, lineBreakMatch.index)}`;
442442
}
443443

444444
const result = repl.useColors ?

0 commit comments

Comments
 (0)