Skip to content

Combination of stylerignore directives and local() leads to problematic styling #1072

@IndrajeetPatil

Description

@IndrajeetPatil

Problem

The following code

# styler: off
skip_if_not_installed("tibble")
local({
  x <- 1
})
# styler: on

is styled to-

# styler: off
local({
  x <- 1
})
skip_if_not_installed("tibble")
local
# styler: on

Note how skip() and local change their positions.

How to reproduce

Run the example code in interactive mode.
If you are looking for a more realistic example, run styler:::style_active_file() on this file.

Note

It's interesting that I can reproduce the issue in the minimal example posted above in the interactive mode, but not in a reprex.

Screenshot 2022-11-26 at 08 54 23

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions