Uh oh!
There was an error while loading. Please reload this page.
Don't strip spaces for regular REPL input - #2246
Conversation
This means ` .method()` isn't misparsed as a REPL keyword, and significantly improves the usability of `.load`.
edef1c
commented
Jul 25, 2015
Expected (and this patch's) behaviour: Current behaviour: |
silverwind
commented
Jul 25, 2015
Fishrock123
commented
Jul 25, 2015
Oops, probably my fault. Hmm, will need to fix this before the 2.5.0 release. |
edef1c
commented
Jul 25, 2015
@Fishrock123 Nah, this has been the case for years. |
thefourtheye
commented
Jul 25, 2015
Hmmm. I knew about this weak REPL command check when I submitted REPL bug fixes PR, but I could not come up with a practical usecase. So, apart from removing the check mentioned in this PR, it would be better if we improved the REPL command check with a regular expression. Instead of if we had it would be better. Also, I would recommend including a test as well. Edit: To me, stripping spaces is not the actual problem here (even though leaving the spaces when we are not inside a string literal is not a big deal), but considering the current line of input as a REPL command just because it starts with Edit 2: It would be better if the RegEx is |
targos
commented
Jul 25, 2015
@thefourtheye you can easily run into this issue by copy-pasting something in the REPL |
thefourtheye
commented
Jul 25, 2015
@targos Yup, I understand that after seeing the example shown in the PR. That is why using a RegEx to validate the string should work here. What do you think? |
targos
commented
Jul 27, 2015
@thefourtheye Yes a RegExp could be the solution. We just need to make sure that it does not identify too much valid JS as a REPL command. |
Fixes the problem shown in nodejs#2246 The REPL module, treats any line which starts with a dot character as a REPL command and this limits the ability to use function calls in the next lines to improve readability. This patch checks if the current line starts with `.` and then a series of lowercase letters and then any characters. For example: > process.version 'v2.4.0' > function sum(arr) { ... return arr ... .reduce(function(c, x) { return x + c; }); Invalid REPL keyword undefined but then, this patches allows this: > process.version 'v2.4.1-pre' > function sum(arr) { ... return arr ... .reduce(function(c, x) { return x + c; }); ... } undefined
jasnell
commented
Nov 16, 2015
@nathan7@thefourtheye@Fishrock123 ... what's the status on this one? |
princejwesley
commented
Dec 24, 2015
@Fishrock123@thefourtheye |
thefourtheye
commented
Dec 25, 2015
@princejwesley I proposed almost the same in #2254. But the problem is, load and save accept filenames as inputs following them. If they had |
princejwesley
commented
Dec 25, 2015
@jasnell@thefourtheye#3835 fixed this issue. |
This means
.method()isn't misparsed as a REPL keyword, and significantly improves the usability of.load.