mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] process multi-line pastes as a single entity
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>
```
45aeb52575
This commit is contained in:
parent
7e93917458
commit
3cab8c087f
1 changed files with 7 additions and 1 deletions
|
|
@ -316,7 +316,13 @@ module IRB
|
|||
Reline.output = @stdout
|
||||
Reline.prompt_proc = @prompt_proc
|
||||
Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
|
||||
if l = readmultiline(@prompt, false, &@check_termination_proc)
|
||||
|
||||
l = readmultiline(@prompt, false) do |line|
|
||||
next false if Reline::IOGate.in_pasting?
|
||||
@check_termination_proc.call(line)
|
||||
end
|
||||
|
||||
if l
|
||||
HISTORY.push(l) if !l.empty?
|
||||
@line[@line_no += 1] = l + "\n"
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue