posit-dev / posit-dev/air

Consider making `foo[[bar]]` and `foo[bar]` never expand when `bar` is "simple"

Open
#199 7 comments 0 reactions 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

See https://github.com/posit-dev/air/issues/183

i.e. with

private$event_callback_counts[[domain]] <- private$event_callback_counts[[domain]] - 1

it should probably never break on the [[ and expand to

private$event_callback_counts[[domain]] <- private$event_callback_counts[[
    domain
  ]] - 
  1

instead it should probably give this, even though the first line exceeds the 80 char limit

private$event_callback_counts[[domain]] <- private$event_callback_counts[[domain]] - 
  1

Related to https://github.com/posit-dev/air/issues/163 because we would not want line breaks in $ to force line breaks here!

We will have to nail down what "simple" means, probably:

  • Keywords like TRUE or NULL
  • Identifiers
  • Numerics / integers / complexes
  • etc

Having a list of what makes something "simple" will likely be useful in other places too?

It should probably also respect persistent line breaks if you manually request the expansion? That's quite an edge case though.

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 reading issues 183 and 163, then use the private$event_callback_counts[[domain]] example as the behavior to clarify. Define which expressions count as “simple,” decide how persistent line breaks interact with manual expansion, and verify that simple [[ and [ expressions avoid unwanted breaks without changing the intended formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.