repl: backslash bug fix
1st commit:
When some string is copied and pasted in REPL, if it has a newline (\n)
in it, then it is considered as end of line and REPL throws a
SyntaxError, because a line cannot end with a unclosed string literal.
This behavior is because of the fact that readline
module breaks at
all the \n
s in the input string and treats them as a seperate line.
So whenever it encounters a new line character it will emit a line
event.
This commit basically reverts 81ea52aa, which was an attempt to improve the way string literals were handled by REPL.
Fixes: #2749 (closed)
2nd commit
As it is, the trimWhitespace function will not remove the white sapce characters at the end of the string, as the greedy capturing group .+ captures everything till end of the string, leaving \s* with nothing.
This patch replaces the buggy function with the built-in, String prototype's trim function.
Note: The second commit is necessary because, the revert brings back the old buggy trimming function. So, I though we could fix it now itself.
cc @silverwind @Fishrock123