Skip to content

General: all indent terminators configurably on own line / Specific: multiline-case-list-terminating : on own line #2632

Description

@rgoldberg

In general, please allow configuring indent to place indentation terminators on their own line; e.g., a multiline-case-list-terminating : would optionally be on its own line, presumably unindented by one level.

// current formatting
case
  .a,
  .b:
  doSomething()
case 

// desired formatting
case
  .a,
  .b
:
  doSomething()
case 

The desired formatting renders .b distinct from doSomething().

It's similar to having an opening or closing parenthesis, bracket, or brace on its own line unindented by one to close out the prior indentation level.

Maybe you want to have each indent terminator configurable individually, but I don't think any configuration exists for opening or closing parentheses, brackets, braces, or any other indentation terminators, either individually or collectively.

I imagine 3 or 4 values for options (whatever the options are named) to configure indentation terminator spacing (individually or collectively) (the comments are just to draw attention; they wouldn't be in actual code):

  1. preserve
  2. attach, e.g.:
    case
      .a,
      .b: // attached
      
    case :
      if
        condition() { // attached
        then()
      }
  3. unindent, e.g.:
    case
      .a,
      .b
    : // unindented
      
    case :
      if
        condition()
      { // unindented
        then()
      }
  4. indent (this seems terrible, so I'd omit it, but I included it here for completeness), e.g.:
    case
      .a,
      .b
      : // indented
      
    case :
      if
        condition()
        { // indented
        then()
      }

It seems that the existing behavior is hardcoded to unindent for closing parentheses, brackets & braces, but to attach for case-list-terminating colons. I haven't verified if existing behavior is preserve or unindent for opening braces or other opening delimiters (I'm just on my phone), or looked for other indentation terminators.

I'd imagine that you'd want the defaults to match existing behavior, though I prefer unindent as the universal default.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions