Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a74a1e

Browse filesBrowse 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 <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>
1 parent 2fa8170 commit 2a74a1e
Copy full SHA for 2a74a1e

File tree

Expand file treeCollapse file tree

3 files changed

+11
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-12
lines changed
Open diff view settings
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+10-10Lines changed: 10 additions & 10 deletions
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) {
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-repl-save-load.js
+1-1Lines changed: 1 addition & 1 deletion
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);
Collapse file

‎test/parallel/test-repl.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl.js
-1Lines changed: 0 additions & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.