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

Apply magic line breaks in left assignment operators #91

Open
gadenbuie opened this issue Dec 11, 2024 · 1 comment
Open

Apply magic line breaks in left assignment operators #91

gadenbuie opened this issue Dec 11, 2024 · 1 comment

Comments

@gadenbuie
Copy link

I often prefer to have the function call, if/else block, or %||% chain on a new line in an assignment:

is_condition_true <- 
  if (condition) {
    "yes"
  } else {
    "no"
  }

base_version <- 
  version %||%
  b_get(brand, "defaults", "shiny", "theme", "version") %||%
  b_get(brand, "defaults", "bootstrap", "version") %||%
  version_default()

Would you consider applying the magic line break logic to the first operator? In other words, the presence of the line break after <- would trigger the above formatting.

@DavisVaughan
Copy link
Collaborator

Yea <- is one of the places we plan to add this. It is mentioned here if you havent seen this draft doc yet (but isn't implemented yet) https://github.com/posit-dev/air/blob/main/docs/formatter.md#left-assignment

@DavisVaughan DavisVaughan changed the title Apply magic line breaks at first operator too Apply magic line breaks in left assignment operators Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants