-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process multi-line pastes as a single entity #202
Conversation
this allows pasting leading-dot chained methods correctly: ```ruby class A def a; self; end def b; true; end end a = A.new a .a .b ``` will properly return `true` instead of erroring on the `.a` line: ``` irb(main):001:1* class A irb(main):002:1* def a; self; end irb(main):003:0> end irb(main):004:0* irb(main):005:0> a = A.new irb(main):006:0* irb(main):007:0> a irb(main):008:0> .a irb(main):009:0> .a => #<A:0x00007f984211fbe8> ```
Looks like a good addition 👍 |
I think it's a really great patch too, and a lot of people will be happy with it. On the other hand, Reline uses "whether the buffer has received a series of keystrokes" as a criterion to determine whether it is pasting or not. So, if there is a delay in I/O due to a slow machine or over the network, it will assume that everything is being pasted. Therefore, with this implementation alone, there is a possibility that the code that should be evaluated immediately (e.g. I'm currently writing an additional patch, so please wait a little longer. |
I added a test example to this branch, but it uses yamatanooroti gem, which has crash problems in Ruby 3.0.0. I added a test example to this branch, but it uses yamatanooroti gem, which has crash problems in Ruby 3.0.0. We are investigating the cause, but for now, please use Ruby 2.7.2 and install |
I've written a patch that evaluates top-level each statement at when multiple statements are pasted at once, d991d11. If I paste below; class A
def b; self; end
def c; true; end
end
a = A.new
a
.b
# aaa
.c
(a)
&.b()
class A def b; self; end; def c; true; end; end;
a = A.new
a
.b
# aaa
.c
(a)
&.b() must be below;
I'll merge this Pull Request if you add a test. And I'll make a another Pull Request with the additional patch later. |
I and @mame fixed the gems and released new versions, so you can use Ruby 3.0.0 to write a test now. |
I'm sorry, I added a test for multiline paste due to release schedule. I'll merge now. This feature is so great for many Ruby users. Thank you so much! |
Heh, no apologies necessary, for getting done what I didn't get around to. Thank you so much! I'm very much looking forward to this feature. |
this allows pasting leading-dot chained methods correctly:
will properly return
true
instead of erroring on the.a
line:I'd be happy to write a test, if you could give me some pointers of how to do so. The only thing I can figure to do is to shell out to
irb
itself, since this is dependent in Reline reading from stdin. Possibly even requiring a pty.