if-else should format to either single line or multiline
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 230
- Forks
- 40
- Avg merge
- 15h 30m
- Merged PRs (30d)
- 1
Description
Describe the bug
formatting an if-else statement where all blocks are considered "one-liners" formats the whole statement as a single line. (great!)
however if one of the blocks is considered a one-liner but others are not, it should abandon the strategy of keeping as single line. that's how other formatters deal with this.
this also applies to try-catch-finally. maybe other things as well.
Script or statement
if true { foo } else { bar | baz | qux }
Actual behavior/output
formats to
if true { foo } else {
bar | baz | qux
}
Expected behavior/output
if true {
foo
} else {
bar | baz | qux
}
Environment
current github versions of nushell and nufmt
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided if true { foo } else { bar | baz | qux } statement using the current nufmt. Trace the formatter’s handling of mixed one-line and multiline blocks, then add a regression test covering if-else and, if applicable, try-catch-finally; done means mixed blocks consistently use multiline formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100