Skip to content

inline_single_stmt_case incorrectly formats if/else #1606

Description

@godalming123

If I have a file called test.odin:

package main

import "core:fmt"

main :: proc() {
	switch 'a' {
	case 'b':
		if true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true {
				if true {
					fmt.println("a")
				} else {
					fmt.println("b")
				}
			}
	}
}

And in my odinfmt.json file I set:

{
  "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/odinfmt.schema.json",
  "inline_single_stmt_case": true,
}

Then, when I run odinfmt -path:test.odin, I get the incorrectly formatted:

package main

import "core:fmt"

main :: proc() {
	switch 'a' {
	case 'b':
		if true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true &&
			   true {
				if true {
					fmt.println("a")
				}
				else {
					fmt.println("b")
				}
			}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions