Skip to content

if-else should format to either single line or multiline #217

Description

@pickx

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions