diff options
author | aycabta <aycabta@gmail.com> | 2019-06-19 09:19:41 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-06-19 09:19:41 +0900 |
commit | d009e321a08d2ca401fceefa638e7e50872f5f54 (patch) | |
tree | e5184b43b181b104d04166a7cbe371d74493cba6 /lib/irb | |
parent | c9729329862a979f2d07d7907c7a515dfcfb2ba4 (diff) | |
download | ruby-d009e321a08d2ca401fceefa638e7e50872f5f54.tar.gz |
Use IRB.conf[:AUTO_INDENT] setting in multiline mode
Diffstat (limited to 'lib/irb')
-rw-r--r-- | lib/irb/input-method.rb | 2 | ||||
-rw-r--r-- | lib/irb/ruby-lex.rb | 37 |
2 files changed, 21 insertions, 18 deletions
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) |