REPL seems to allow two newlines before deciding that the end of input is premature.
I do not know if it is intended, but you can cheat it like this:
julia> [i for i in
1:1]
1-element Array{Int64,1}:
1
julia> [i for i in
1:1]
1-element Array{Int64,1}:
1
julia> [i for i in
1:1]
1-element Array{Int64,1}:
1
Here I obtained the second and third expression by going back the command history deleting 1:1], pressing two newlines, and reinserting 1:1]. Adding three newlines produces an error.
To clarify: the intent of this question is to establish whether this is intended behavior or a bug before opening an issue.
If this is intended, it should be documented (I could not find it, but perhaps I was not looking at the right place). That said, my life would be much easier if this was a considered a bug and got fixed accordingly, otherwise I will have to so some magic to remove newlines from code (but not strings etc).
There is a paste mode (bracket paste) which is automatically enabled when pasting (in most terminals). This can be opted into by plugin by sending the correct ansi sequence to the repl, see https://cirw.in/blog/bracketed paste.
I think that @keno implemented this way back in the day and that it’s intentional. I’ve never used this feature personally, so I don’t really care if it stays or goes, but he may have more thoughts.
Yes, it’s intentional. It’s there so people get a syntax error when they have incomplete sequences but don’t think they do. As was mentioned, use bracketed paste mode for pasting expressions.
It does have the advantage that when someone gets frustrated and keeps hitting return, they eventually get an error and a new prompt instead of just a seemingly hung REPL.
Thanks. Bracketed paste solves my problems and I can see the rationale for this, so I am fine with it, just didn’t know about it.
But if I wanted to submit a PR documenting this (breaking out after 3 newlines, using Alt-Enter, mention bracketed paste mode), where should it go? Workflow tips?