diff options
-rw-r--r-- | lib/irb.rb | 2 | ||||
-rw-r--r-- | lib/irb/input-method.rb | 2 | ||||
-rw-r--r-- | lib/irb/ruby-lex.rb | 37 |
3 files changed, 23 insertions, 18 deletions
diff --git a/lib/irb.rb b/lib/irb.rb index 2c7b17da6b..5ba0679501 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -491,6 +491,8 @@ module IRB end end + @scanner.set_auto_indent(@context) if @context.auto_indent_mode + @scanner.each_top_level_statement do |line, line_no| signal_status(:IN_EVAL) do begin diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index dbed7da14b..bde6ccdc69 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -255,7 +255,7 @@ module IRB Reline.input = @stdin Reline.output = @stdout Reline.prompt_proc = @prompt_proc - Reline.auto_indent_proc = @auto_indent_proc + Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc if l = readmultiline(@prompt, false, &@check_termination_proc) HISTORY.push(l) if !l.empty? @line[@line_no += 1] = l + "\n" diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index ad3a285f02..e5c8b14b59 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -53,7 +53,26 @@ class RubyLex result end end - if @io.respond_to?(:auto_indent) + if p.respond_to?(:call) + @input = p + elsif block_given? + @input = block + else + @input = Proc.new{@io.gets} + end + end + + def set_prompt(p = nil, &block) + p = block if block_given? + if p.respond_to?(:call) + @prompt = p + else + @prompt = Proc.new{print p} + end + end + + def set_auto_indent(context) + if @io.respond_to?(:auto_indent) and context.auto_indent_mode @io.auto_indent do |lines, line_index, byte_pointer, is_newline| if is_newline md = lines[line_index - 1].match(/(\A +)/) @@ -82,22 +101,6 @@ class RubyLex end end end - if p.respond_to?(:call) - @input = p - elsif block_given? - @input = block - else - @input = Proc.new{@io.gets} - end - end - - def set_prompt(p = nil, &block) - p = block if block_given? - if p.respond_to?(:call) - @prompt = p - else - @prompt = Proc.new{print p} - end end def check_state(code) |