Skip to content

Commit 0869ef3

Browse files
Zirakrvagg
authored andcommitted
repl: allow leading period in multiline input
When writing multiline input, one can't chain function calls as if the lines begin with a period, since those are treated as REPL commands. Before: > ([0, 1, 2] ... .map(x => x + 1)) Invalid REPL keyword After: > ([0, 1, 2] ... .map(x => x + 1)) [ 1, 2, 3 ] PR-URL: #3835 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 2b5b127 commit 0869ef3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/repl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ function REPLServer(prompt,
391391
var rest = matches && matches[2];
392392
if (self.parseREPLKeyword(keyword, rest) === true) {
393393
return;
394-
} else {
394+
} else if (!self.bufferedCommand) {
395395
self.outputStream.write('Invalid REPL keyword\n');
396396
skipCatchall = true;
397397
}

test/parallel/test-repl.js

+5
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ function error_test() {
117117
expect: prompt_multiline },
118118
{ client: client_unix, send: '+ ".2"}`',
119119
expect: `'io.js 1.0.2'\n${prompt_unix}` },
120+
// Dot prefix in multiline commands aren't treated as commands
121+
{ client: client_unix, send: '("a"',
122+
expect: prompt_multiline },
123+
{ client: client_unix, send: '.charAt(0))',
124+
expect: `'a'\n${prompt_unix}` },
120125
// Floating point numbers are not interpreted as REPL commands.
121126
{ client: client_unix, send: '.1234',
122127
expect: '0.1234' },

0 commit comments

Comments
 (0)