posit-dev / posit-dev/air

Wrapping at infix operator in long if statement chain

Open
#234 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
446
Forks
32
Avg merge
16h 48m
Merged PRs (30d)
1

Description

Just bumped into this in the wild (i.e. code I didn't write in chromote). I expected no change to the following code,

if (
  domain %in% private$session$get_auto_events() &&
    private$event_callback_counts[[domain]] == 1 &&
    isTRUE(private$event_enable_domains[[domain]])
) {
  private$session$debug_log("Enabling events for ", domain)
  private$session[[domain]]$enable()
}

but air format introduces a line break after the %in%:

if (
  domain %in%
    private$session$get_auto_events() &&
    private$event_callback_counts[[domain]] == 1 &&
    isTRUE(private$event_enable_domains[[domain]])
) {
  private$session$debug_log("Enabling events for ", domain)
  private$session[[domain]]$enable()
}

It's not a new change, this repros back to air 0.1.1.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running air on the R reproducer in this issue and compare the output with air 0.1.1, where the behavior also reproduces. Trace the formatter path responsible for wrapping the infix operator; done means the long if statement remains formatted without a break immediately after %in%.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.