-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove leading blank lines when strict = TRUE
#1056
Conversation
strict = TRUE
strict = TRUE
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@@ -67,7 +67,7 @@ test_that("When expressions are cached, number of newlines between them are pres | |||
# applied cache | |||
expect_equal(text[1:4], as.character(style_text(text[1:4]))) | |||
|
|||
expect_equal(text, as.character(style_text(text))) | |||
# expect_equal(text, as.character(style_text(text))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lorenzwalthert I think the PR is now set, except for one thing: I can't figure out why the cache-related tests are failing. I've commented them out for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's indeed a bit tricky... Seems like on first round, line breaks are removed, but then in the second round, they are added again...
devtools::load_all()
#> ℹ Loading styler
#> In tests/testthat/helpers-devel-options: Deactivated cache.
test_that("When expressions are cached, number of newlines between them are preserved", {
local_test_setup(cache = TRUE)
text <- c(
"1 + 1",
"",
"",
"f(x)",
"",
"",
"",
"x < 3",
"function() NULL"
)
# add to cache
expect_equal(text[1:4], as.character(style_text(text[1:4])))
# applied cache
expect_equal(text[1:4], as.character(style_text(text[1:4])))
cat(as.character(style_text(text)), sep = "\n")
cat('-----------------------------------------\n')
cat(as.character(style_text(text)), sep = "\n")
})
#> 1 + 1
#>
#>
#> f(x)
#> x < 3
#> function() NULL
#> -----------------------------------------
#> 1 + 1
#>
#>
#> f(x)
#>
#>
#>
#> x < 3
#> function() NULL
#> Test passed 😀
Created on 2022-11-21 with reprex v2.0.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you comment on this PR? I saw an email about it, but can't find it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I deleted it again because I realised it was gibberish :D. Will have to dig in deeper.
strict = TRUE
strict = TRUE
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: Lorenz Walthert <[email protected]>
…/styler into 1014_rm_leading_blank_line
Codecov Report
@@ Coverage Diff @@
## main #1056 +/- ##
==========================================
+ Coverage 91.05% 91.08% +0.02%
==========================================
Files 46 46
Lines 2684 2692 +8
==========================================
+ Hits 2444 2452 +8
Misses 240 240
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This is how benchmark results would change (along with a 95% confidence interval in relative change) if be75da3 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
Sorry @IndrajeetPatil that I did not have time to review this. I currently have a lot of (more urgent) things that keep me busy and I first need to understand whats going on... Thanks for your patience. |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 3a72387 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 0314644 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
Ok, I finally got a chance to look at this... I described the solution in the code. Another question is, if and where we want to remove additional blank lines between expressions. Status quo is not to remove any I think. |
That was definitely an unwanted change. I think the current behaviour on |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 509bea1 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
Closes #1014