diff options
author | Ben <kanobt61@gmail.com> | 2019-12-30 11:18:05 -0500 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-01-14 15:40:38 +0900 |
commit | 9994eb8a5e72ff68ee2a13ddeff8d9307ba7cd84 (patch) | |
tree | 2764df9b1d270b40691b042de793032843bf949e /ext/nkf | |
parent | 440013b2fa73d12aeb4027bb8d8d237ea8700099 (diff) | |
download | ruby-9994eb8a5e72ff68ee2a13ddeff8d9307ba7cd84.tar.gz |
[ruby/irb] Fix newline depth with multiple braces
This commit fixes the check_newline_depth_difference method to multiple
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 definition 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 same
way as we do `end` and allow check_corresponding_token_depth to pop the
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
Diffstat (limited to 'ext/nkf')
0 files changed, 0 insertions, 0 deletions