Skip to content

variable_call_indent leaks too much DefaultStyle stuff through #1069

Description

@penelopeysm

YASStyle + variable_call_indent is quite largely implemented by deferring to DefaultStyle (this is in both p_call and n_call!). However, this leaks quite a fair bit of DefaultStyle formatting decisions through. For example:

julia> s = "f(a, b)"

julia> ft(s, YASStyle()) |> println
f(a, b)


julia> ft(s, YASStyle(); margin=1) |> println
f(a,
  b)


julia> ft(s, YASStyle(); margin=1, variable_call_indent=["f"]) |> println
f(
  a,
  b,
  )

I would expect the last two to give the same results. The issue here is that DefaultStyle will insert placeholders after the opening paren and before the closing paren:

julia> fs(:fst, s, YASStyle(); margin=1, variable_call_indent=["f"])
TopLevel 1 lines=1-1 indent=0 len=7
nest_behavior=AllowNest extra_margin=0
└── [1] Call 10 lines=1-1 indent=0 len=7
    nest_behavior=AllowNest extra_margin=0
    ├── [1] IDENTIFIER lines=1-1 val="f"
    │       line_offset=1 indent=0
    ├── [2] PUNCTUATION lines=1-1 val="("
    │       line_offset=2 indent=0
    ├── [3] PLACEHOLDER lines=1-1 val=""
    │       line_offset=-1 indent=0
    ├── [4] IDENTIFIER lines=1-1 val="a"
    │       line_offset=3 indent=0
    ├── [5] PUNCTUATION lines=1-1 val=","
    │       line_offset=4 indent=0
    ├── [6] PLACEHOLDER lines=1-1 val=" "
    │       line_offset=-1 indent=0
    ├── [7] IDENTIFIER lines=1-1 val="b"
    │       line_offset=6 indent=0
    ├── [8] TRAILINGCOMMA lines=1-1 val=""
    │       line_offset=-1 indent=0
    ├── [9] PLACEHOLDER lines=1-1 val=""
    │       line_offset=-1 indent=0
    └── [10] PUNCTUATION lines=1-1 val=")"
            line_offset=7 indent=0

whereas plain old YASStyle won't.

julia> fs(:fst, s, YASStyle(); margin=1)
TopLevel 1 lines=1-1 indent=0 len=7
nest_behavior=AllowNest extra_margin=0
└── [1] Call 8 lines=1-1 indent=0 len=7
    nest_behavior=AllowNest extra_margin=0
    ├── [1] IDENTIFIER lines=1-1 val="f"
    │       line_offset=1 indent=0
    ├── [2] PUNCTUATION lines=1-1 val="("
    │       line_offset=2 indent=0
    ├── [3] IDENTIFIER lines=1-1 val="a"
    │       line_offset=3 indent=0
    ├── [4] PUNCTUATION lines=1-1 val=","
    │       line_offset=4 indent=0
    ├── [5] PLACEHOLDER lines=1-1 val=" "
    │       line_offset=-1 indent=0
    ├── [6] IDENTIFIER lines=1-1 val="b"
    │       line_offset=6 indent=0
    ├── [7] TRAILINGCOMMA lines=1-1 val=""
    │       line_offset=-1 indent=0
    └── [8] PUNCTUATION lines=1-1 val=")"
            line_offset=7 indent=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Priority 3 — see contributing docs

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions