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: https://github.com/nodejs/node/pull/26240 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
197690972c
commit
df43754fe1
20
lib/repl.js
20
lib/repl.js
@ -1479,16 +1479,16 @@ function defineDefaultCommands(repl) {
|
||||
this.displayPrompt();
|
||||
}
|
||||
});
|
||||
|
||||
repl.defineCommand('editor', {
|
||||
help: 'Enter editor mode',
|
||||
action() {
|
||||
if (!this.terminal) return;
|
||||
_turnOnEditorMode(this);
|
||||
this.outputStream.write(
|
||||
'// Entering editor mode (^D to finish, ^C to cancel)\n');
|
||||
}
|
||||
});
|
||||
if (repl.terminal) {
|
||||
repl.defineCommand('editor', {
|
||||
help: 'Enter editor mode',
|
||||
action() {
|
||||
_turnOnEditorMode(this);
|
||||
this.outputStream.write(
|
||||
'// Entering editor mode (^D to finish, ^C to cancel)\n');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function regexpEscape(s) {
|
||||
|
@ -61,7 +61,7 @@ assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
|
||||
'}'
|
||||
];
|
||||
const putIn = new ArrayStream();
|
||||
const replServer = repl.start('', putIn);
|
||||
const replServer = repl.start({ terminal: true, stream: putIn });
|
||||
|
||||
putIn.run(['.editor']);
|
||||
putIn.run(cmds);
|
||||
|
@ -439,7 +439,6 @@ const errorTests = [
|
||||
expect: [
|
||||
/\.break/,
|
||||
/\.clear/,
|
||||
/\.editor/,
|
||||
/\.exit/,
|
||||
/\.help/,
|
||||
/\.load/,
|
||||
|
Loading…
x
Reference in New Issue
Block a user