diff options
author | aycabta <[email protected]> | 2020-12-26 23:34:27 +0900 |
---|---|---|
committer | aycabta <[email protected]> | 2021-01-05 18:04:45 +0900 |
commit | cce72a24119b5c2177100865f52376ca4b32bd9d (patch) | |
tree | ea1540b10612ce97737f7aab869255dc3e1bc01c /lib/irb/ruby-lex.rb | |
parent | e91160f7579a572e198067b9c0697c91be1876e7 (diff) |
[ruby/irb] Newline in oneliner def doesn't reset indent
This closes ruby/irb#132.
https://github.com/ruby/irb/commit/43456dcf5e
Diffstat (limited to 'lib/irb/ruby-lex.rb')
-rw-r--r-- | lib/irb/ruby-lex.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 9914aece5e..68751b4de1 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -410,7 +410,7 @@ class RubyLex case t[1] when :on_ignored_nl, :on_nl, :on_comment - if index != (@tokens.size - 1) + if index != (@tokens.size - 1) and in_oneliner_def != :BODY depth_difference = 0 open_brace_on_line = 0 end @@ -488,11 +488,13 @@ class RubyLex 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 - open_brace_on_line = 0 + if in_oneliner_def != :BODY + corresponding_token_depth = nil + spaces_at_line_head = 0 + is_first_spaces_of_line = true + is_first_printable_of_line = true + open_brace_on_line = 0 + end next when :on_sp spaces_at_line_head = t[2].count(' ') if is_first_spaces_of_line |