Skip to content

Commit 2a74a1e

Browse files
BridgeARaddaleax
authored andcommitted
repl: hide editor mode if not used in a terminal
The editor mode is only useable when used as terminal. Hide it from the user in case the repl terminal option is not set. PR-URL: #26240 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 2fa8170 commit 2a74a1e

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

lib/repl.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1477,16 +1477,16 @@ function defineDefaultCommands(repl) {
14771477
this.displayPrompt();
14781478
}
14791479
});
1480-
1481-
repl.defineCommand('editor', {
1482-
help: 'Enter editor mode',
1483-
action() {
1484-
if (!this.terminal) return;
1485-
_turnOnEditorMode(this);
1486-
this.outputStream.write(
1487-
'// Entering editor mode (^D to finish, ^C to cancel)\n');
1488-
}
1489-
});
1480+
if (repl.terminal) {
1481+
repl.defineCommand('editor', {
1482+
help: 'Enter editor mode',
1483+
action() {
1484+
_turnOnEditorMode(this);
1485+
this.outputStream.write(
1486+
'// Entering editor mode (^D to finish, ^C to cancel)\n');
1487+
}
1488+
});
1489+
}
14901490
}
14911491

14921492
function regexpEscape(s) {

test/parallel/test-repl-save-load.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
6161
'}'
6262
];
6363
const putIn = new ArrayStream();
64-
const replServer = repl.start('', putIn);
64+
const replServer = repl.start({ terminal: true, stream: putIn });
6565

6666
putIn.run(['.editor']);
6767
putIn.run(cmds);

test/parallel/test-repl.js

-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ const errorTests = [
439439
expect: [
440440
/\.break/,
441441
/\.clear/,
442-
/\.editor/,
443442
/\.exit/,
444443
/\.help/,
445444
/\.load/,

0 commit comments

Comments
 (0)