Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid extra indentation on Go switches #6817

Merged
merged 1 commit into from
Apr 25, 2023

Commits on Apr 25, 2023

  1. runtime: avoid extra indentation on Go switches

    Unlike other languages, in Go, switches themselves are not indented;
    it's just each case body which is indented by one level:
    
       switch foo {
       case "bar":
          baz()
       }
    
    As such, we shouldn't @indent for type_switch_statement nor
    expression_switch_statement, as otherwise inserted lines show up as:
    
       switch foo {
          // inserted with "o"
       case "bar":
             // inserted with "o"
          baz()
       }
    
    With the fix, the inserted lines are indented properly:
    
       switch foo {
       // inserted with "o"
       case "bar":
          // inserted with "o"
          baz()
       }
    
    I also verified that indentation on selects similarly works well.
    
    Thanks to Triton171 for helping with this fix.
    
    Fixes helix-editor#6772.
    mvdan committed Apr 25, 2023
    Configuration menu
    Copy the full SHA
    d5a0f1a View commit details
    Browse the repository at this point in the history