| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 397be8a commit 85b3edc
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -436,9 +436,9 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) { | |||
| 436 | 436 | ||
| 437 | 437 | // Line breaks are very rare and probably only occur in case of error | |
| 438 | 438 | // 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)}`; | ||
| 442 | 442 | } | |
| 443 | 443 | ||
| 444 | 444 | const result = repl.useColors ? | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const ArrayStream = require('../common/arraystream'); | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + const repl = require('repl'); | ||
| 7 | + | ||
| 8 | + common.skipIfInspectorDisabled(); | ||
| 9 | + | ||
| 10 | + const inputStream = new ArrayStream(); | ||
| 11 | + const outputStream = new ArrayStream(); | ||
| 12 | + repl.start({ | ||
| 13 | + input: inputStream, | ||
| 14 | + output: outputStream, | ||
| 15 | + useGlobal: false, | ||
| 16 | + terminal: true, | ||
| 17 | + useColors: true | ||
| 18 | + }); | ||
| 19 | + | ||
| 20 | + let output = ''; | ||
| 21 | + outputStream.write = (chunk) => output += chunk; | ||
| 22 | + | ||
| 23 | + for (const char of ['\\n', '\\v', '\\r']) { | ||
| 24 | + inputStream.emit('data', `"${char}"()`); | ||
| 25 | + // Make sure the output is on a single line | ||
| 26 | + assert.strictEqual(output, `"${char}"()\n\x1B[90mTypeError: "\x1B[39m\x1B[9G\x1B[1A`); | ||
| 27 | + inputStream.run(['']); | ||
| 28 | + output = ''; | ||
| 29 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments