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
@ -1479,16 +1479,16 @@ function defineDefaultCommands(repl) {
|
|||||||
this.displayPrompt();
|
this.displayPrompt();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (repl.terminal) {
|
||||||
repl.defineCommand('editor', {
|
repl.defineCommand('editor', {
|
||||||
help: 'Enter editor mode',
|
help: 'Enter editor mode',
|
||||||
action() {
|
action() {
|
||||||
if (!this.terminal) return;
|
|
||||||
_turnOnEditorMode(this);
|
_turnOnEditorMode(this);
|
||||||
this.outputStream.write(
|
this.outputStream.write(
|
||||||
'// Entering editor mode (^D to finish, ^C to cancel)\n');
|
'// Entering editor mode (^D to finish, ^C to cancel)\n');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function regexpEscape(s) {
|
function regexpEscape(s) {
|
||||||
|
@ -61,7 +61,7 @@ assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
|
|||||||
'}'
|
'}'
|
||||||
];
|
];
|
||||||
const putIn = new ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
const replServer = repl.start('', putIn);
|
const replServer = repl.start({ terminal: true, stream: putIn });
|
||||||
|
|
||||||
putIn.run(['.editor']);
|
putIn.run(['.editor']);
|
||||||
putIn.run(cmds);
|
putIn.run(cmds);
|
||||||
|
@ -439,7 +439,6 @@ const errorTests = [
|
|||||||
expect: [
|
expect: [
|
||||||
/\.break/,
|
/\.break/,
|
||||||
/\.clear/,
|
/\.clear/,
|
||||||
/\.editor/,
|
|
||||||
/\.exit/,
|
/\.exit/,
|
||||||
/\.help/,
|
/\.help/,
|
||||||
/\.load/,
|
/\.load/,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user