Skip to content

Allow specifying AsIs scope without including lower-level transformations #703

Closed

Description

@lorenzwalthert

When you select scope = 'tokens', you implicitly choose to select also spaces, indention, line break, i.e. scope is cummulative. See help(tidyverse_style, package = 'styler'). For certain applications, you don't want to have lower-level transformations, i.e. for indenting lines for vscode, you don't want to style spaces. I think we might simply want to use I() to indicate non-cummulative scopes. I() changes the class to AsIs and we can handle this internally. This is a non-breaking API change:

style_text("1+\n1", scope = I("indention")) # to only style indention
style_text("1+\n1", scope = I(c("spaces", "token")) # spaces and token only
style_text("1+\n1", scope = "indention") # spaces and indention

Internals probably should be refactored to operate on a factor vector with scopes instead of the highest-level scope. Note that this will invalidate the cache as the scope argument will now be represented differently internally.

cc: @renkun-ken.

Activity

  1. changed the title [-]Allow specifying non-cummulative scope[/-] [+]Allow specifying AsIs scope without including lower-level transformations[/+] on Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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