Skip to content

Commit

Permalink
Merge pull request #162 from ushitora-anqou/master
Browse files Browse the repository at this point in the history
Fix odd indentation of nested one liner "if" statement ( #128 )
  • Loading branch information
gingermusketeer authored Mar 4, 2019
2 parents 108bf39 + b35d27c commit 6e131b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Fix odd indentation of nested one liner "if" statements (issue [128](https://github.com/ruby-formatter/rufo/issues/128))

### Added
- Ignore `vendor` directories from files to be checked. This allows rufo to be run without any arguments against a directory both locally and on common CI tools without needing any configuration.
- Allow logging level to be configured with `--loglevel[=LEVEL]`.
Expand Down
2 changes: 1 addition & 1 deletion lib/rufo/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2819,7 +2819,7 @@ def visit_if_or_unless(node, keyword, check_end: true)
if (else_body = node[3])
# [:else, else_contents]
# [:elsif, cond, then, else]
write_indent
write_indent if @line != line

case else_body[0]
when :else
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/rufo/formatter_source_specs/if.rb.spec
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,15 @@ end
if 1
2
end

#~# ORIGINAL

if 1
if 2 then 3 else 4 end
end

#~# EXPECTED

if 1
if 2 then 3 else 4 end
end

0 comments on commit 6e131b2

Please sign in to comment.