Skip to content

Commit afd0c77

Browse files
committed
fixup!
1 parent 1eb1502 commit afd0c77

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

lib/internal/repl/highlight.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function highlight(code) {
5656
let result = '';
5757
let offset = 0;
5858
function write(start, end, style) {
59-
result +=
59+
result +=
6060
StringPrototypeSlice(code, offset, start) +
6161
stylizeWithColor(StringPrototypeSlice(code, start, end), style);
6262
offset = end;

test/parallel/test-repl-preview-newlines.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ import { startNewREPLServer } from '../common/repl.js';
44

55
common.skipIfInspectorDisabled();
66

7-
const { output, run, replServer } = startNewREPLServer({ useColors: true });
7+
// Ignore terminal settings so the preview remains active under TERM=dumb.
8+
process.env.TERM = '';
9+
10+
// Keep syntax highlighting out of this test so it only covers preview layout.
11+
// Preview and result colors are enabled after readline is initialized.
12+
const { output, run, replServer } = startNewREPLServer({ useColors: false });
13+
replServer.useColors = true;
14+
replServer.writer.options.colors = true;
815

916
for (const char of ['\\n', '\\v', '\\r']) {
1017
output.accumulator = '';

test/parallel/test-repl-preview.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ async function tests(options) {
8383
prompt: PROMPT,
8484
stream: new REPLStream(),
8585
ignoreUndefined: true,
86-
useColors: true,
86+
// Keep syntax highlighting out of these preview transcript assertions.
87+
// Preview and result colors are enabled after readline is initialized.
88+
useColors: false,
8789
...options
8890
});
91+
repl.useColors = true;
92+
repl.writer.options.colors = true;
8993

9094
await runAndWait([
9195
'function foo(x) { return x; } ' +

test/parallel/test-repl-reverse-search.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ function runTest() {
324324
}),
325325
completer: opts.completer,
326326
prompt,
327-
useColors: opts.useColors || false,
327+
// Keep syntax highlighting out of the reverse-search transcript. Result
328+
// colors are enabled below after readline has been initialized.
329+
useColors: false,
328330
terminal: true
329331
}, common.mustCall((err, repl) => {
330332
if (err) {
@@ -346,6 +348,11 @@ function runTest() {
346348
setImmediate(runTestWrap, true);
347349
}));
348350

351+
if (opts.useColors) {
352+
repl.useColors = true;
353+
repl.writer.options.colors = true;
354+
}
355+
349356
if (opts.columns) {
350357
Object.defineProperty(repl, 'columns', {
351358
value: opts.columns,

0 commit comments

Comments
 (0)