Repository navigation
Support for curly-curly syntactic sugar - #528
Merged
Merged
Conversation
Collaborator
Author
|
The problem with this PR is that it does not allow # this is bad when the function call name + indention is so long that we simply want the
# first argument on a new line.
styler::style_text(
"call(
{{x}}
)"
)
#> call({{ x }})
# or less common
styler::style_text(
"call(1, 2, 3, 4,
4, 5,
{{x}},
5
)"
)
#> call(
#> 1, 2, 3, 4,
#> 4, 5, {{ x }},
#> 5
#> )Created on 2019-06-29 by the reprex package (v0.2.1) |
E.g. call({{\nx }}\n) should be left as is. Because we can't look into the future 2 steps (token_after), we need to compute the token ad-hoc, check if it is {, and if yes, we know it is a curly-curly expression. Leaves the minor edge case of an expression starting with `{{` but not being a curly-curly expression (e.g. `call(\n{{1} + 2})`) treated inconsistently beause we assume here it is a curly curly expression (as we only check for `{{` in the beginning. Result, first `{` is moved to the new line.
… not a child of pd and rules setting line breaks before that token is not within the scope of this function (plus you get an error with .rm_break_idx + 1L.
lorenzwalthert
force-pushed
the
feature-curly-curly
branch
from
June 30, 2019 15:18
5a1c0d4 to
ba2d45d
Compare
Collaborator
Author
|
Problem from above resolved with ba2d45d: styler::style_text(
"call(
{{x}}
)"
)
#> call(
#> {{ x }}
#> )
# or less common
styler::style_text(
"call(1, 2, 3, 4,
4, 5,
{{x}},
5
)"
)
#> call(
#> 1, 2, 3, 4,
#> 4, 5,
#> {{ x }},
#> 5
#> )Created on 2019-06-30 by the reprex package (v0.2.1) |
Closed
This was referenced Oct 13, 2019
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #526. Affecting both line break rules and spacing rules. Preserve testing of previous code (mostly focussed on indention) related to using two curly braces in a sequence was preserved, as we need this to work independently of the rule for
{{. This is implemented using a version of the tidyverse style guide that turns off the rule for curly-curly.