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

Alignment in switch() statements is not preserved when elements are missing #1025

Open
IndrajeetPatil opened this issue Oct 5, 2022 · 1 comment

Comments

@IndrajeetPatil
Copy link
Collaborator

When no elements missing: alignment preserved

styler::style_text(text = "
  switch(
    word,
    a   = 1,
    ab  = 2,
    abc = 3
  )")
#> 
#> switch(word,
#>   a   = 1,
#>   ab  = 2,
#>   abc = 3
#> )

When elements missing: alignment not preserved

styler::style_text(text = "
  switch(
    word,
    a   = 1,
    ab  = ,
    abc = 3
  )")
#> 
#> switch(word,
#>   a = 1,
#>   ab = ,
#>   abc = 3
#> )

Created on 2022-10-05 with reprex v2.0.2

Expected

#> switch(word,
#>   a   = 1,
#>   ab  =  ,
#>   abc = 3
#> )
@IndrajeetPatil IndrajeetPatil changed the title Assignment alignment in switch() statements is not preserved when elements are missing Alignment in switch() statements is not preserved when elements are missing Oct 7, 2022
@lorenzwalthert
Copy link
Collaborator

I am not sure I consider

switch(
    word,
    a   = 1,
    ab  = ,
    abc = 3
  )

Aligned. I think it had to be

switch(
    word,
    a   = 1,
    ab  =  ,
    abc = 3
  )

But even then, it does not give the expected result.

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

No branches or pull requests

2 participants