summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-06-19 09:19:41 +0900
committeraycabta <aycabta@gmail.com>2019-06-19 09:19:41 +0900
commitd009e321a08d2ca401fceefa638e7e50872f5f54 (patch)
treee5184b43b181b104d04166a7cbe371d74493cba6 /lib
parentc9729329862a979f2d07d7907c7a515dfcfb2ba4 (diff)
Use IRB.conf[:AUTO_INDENT] setting in multiline mode
Diffstat (limited to 'lib')
-rw-r--r--lib/irb.rb2
-rw-r--r--lib/irb/input-method.rb2
-rw-r--r--lib/irb/ruby-lex.rb37
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)