Skip to content

Commit

Permalink
repl: hide editor mode if not used in a terminal
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
BridgeAR authored and danbev committed Feb 28, 2019
1 parent 1976909 commit df43754
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
20 changes: 10 additions & 10 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-save-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ const errorTests = [
expect: [
/\.break/,
/\.clear/,
/\.editor/,
/\.exit/,
/\.help/,
/\.load/,
Expand Down

0 comments on commit df43754

Please sign in to comment.