From 6b8eca463563a5115d3b8c1173516529ceb2c7f9 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 14 Dec 2019 16:07:21 +0900 Subject: [PATCH 1/2] Fix auto-indent for `1.times do` Fixes #47 --- lib/irb/ruby-lex.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 24074f323..a012d49f6 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -336,7 +336,7 @@ def check_newline_depth_difference next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME) case t[2] when 'do' - if index > 0 and @tokens[index - 1][3].anybits?(Ripper::EXPR_CMDARG | Ripper::EXPR_ENDFN) + if index > 0 and @tokens[index - 1][3].anybits?(Ripper::EXPR_CMDARG | Ripper::EXPR_ENDFN | Ripper::EXPR_ARG) # method_with_block do; end depth_difference += 1 else From ab207353d3bef6c07f22c3bef82b759747e29d50 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 14 Dec 2019 16:14:43 +0900 Subject: [PATCH 2/2] Make nesting level up for `1.times do` Follow up of the previous commit --- lib/irb/ruby-lex.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index a012d49f6..b4c31c16f 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -293,7 +293,7 @@ def process_nesting_level next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME) case t[2] when 'do' - if index > 0 and @tokens[index - 1][3].anybits?(Ripper::EXPR_CMDARG | Ripper::EXPR_ENDFN) + if index > 0 and @tokens[index - 1][3].anybits?(Ripper::EXPR_CMDARG | Ripper::EXPR_ENDFN | Ripper::EXPR_ARG) # method_with_block do; end indent += 1 else