ruby-changes:59048
From: aycabta <ko1@a...>
Date: Tue, 3 Dec 2019 13:04:17 +0900 (JST)
Subject: [ruby-changes:59048] 027e847cd2 (master): Fix auto-indent behavior correctly
https://git.ruby-lang.org/ruby.git/commit/?id=027e847cd2 From 027e847cd2540553c9ddcf1b39028c43258a3fb4 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Tue, 3 Dec 2019 13:02:01 +0900 Subject: Fix auto-indent behavior correctly diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 1761afe..24074f3 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -366,9 +366,9 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L366 spaces_of_nest = [] spaces_at_line_head = 0 @tokens.each_with_index do |t, index| - corresponding_token_depth = nil case t[1] when :on_ignored_nl, :on_nl, :on_comment + corresponding_token_depth = nil spaces_at_line_head = 0 is_first_spaces_of_line = true is_first_printable_of_line = true diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 5d325bc..072238f 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -815,12 +815,9 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L815 @line = ' ' * new_indent + @line.lstrip new_indent = nil - (new_lines[-2].size + 1).times do |n| - result = @auto_indent_proc.(new_lines[0..-2], @line_index - 1, n, false) - if result - new_indent = result - break - end + result = @auto_indent_proc.(new_lines[0..-2], @line_index - 1, (new_lines[-2].size + 1), false) + if result + new_indent = result end if new_indent&.>= 0 @line = ' ' * new_indent + @line.lstrip -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/