[ruby-cvs:79144] 9994eb8a5e (master): [ruby/irb] Fix newline depth with multiple braces

"Ben" <[email protected]> Tue, 14 Jan 2020 15:45:00 +0900 (JST)
Newsgroups gmane.comp.lang.ruby.cvs
Message-ID <[email protected]>
Ben	2019-12-31 01:18:05 +0900 (Tue, 31 Dec 2019)

  New Revision: 9994eb8a5e

  https://github.com/ruby/ruby/commit/9994eb8a5e

  Log:
    [ruby/irb] Fix newline depth with multiple braces
    =

    This commit fixes the check_newline_depth_difference method to multip=
le
    open braces on one line into account. Before this change we were
    subtracting from the depth in check_newline_depth_difference on
    every open brace. This is the right thing to do if the opening and
    closing brace are on the same line. For example in a method definitio=
n we
    have an opening and closing parentheses we want to add 1 to our depth=
,
    and then remove it.
    =

    ```
    def foo()
    end
    ```
    =

    However this isn't the correct behavior when the brace spans multiple=

    lines. If a brace spans multiple lines we don't want to subtract from=

    check_newline_depth_difference and we want to treat the braces the sa=
me
    way as we do `end` and allow check_corresponding_token_depth to pop t=
he
    correct depth.
    =

    Example of bad behavior:
    =

    ```
    def foo()
      [
      ]
    puts 'bar'
    end
    ```
    =

    Example of desired behavior:
    =

    ```
    def foo()
      [
      ]
      puts 'bar'
    end
    ```
    =

    https://github.com/ruby/irb/commit/7dc8af01e0

  Modified files:
    lib/irb/ruby-lex.rb
    test/irb/test_ruby_lex.rb=