-
Notifications
You must be signed in to change notification settings - Fork 73
styling with styler #170
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
styling with styler #170
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ update_indention_ref_fun_call <- function(pd_nested) { | |
non_comment <- which(pd_nested$token != "COMMENT") | ||
first_non_comment_after_call <- non_comment[non_comment > 2][1] | ||
if ((current_is_call) && | ||
nrow(pd_nested) > 3 && | ||
pd_nested$lag_newlines[first_non_comment_after_call] == 0) { | ||
nrow(pd_nested) > 3 && | ||
pd_nested$lag_newlines[first_non_comment_after_call] == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Desired? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good. |
||
candidates <- 3:(nrow(pd_nested) - 1) | ||
|
||
child_is_call <- map_lgl(pd_nested$child, is_function_call) | ||
|
@@ -58,7 +58,7 @@ update_indention_ref_fun_call <- function(pd_nested) { | |
#' } | ||
update_indention_ref_fun_dec <- function(pd_nested) { | ||
if (pd_nested$token[1] == "FUNCTION" && | ||
nrow(pd_nested) > 3) { | ||
nrow(pd_nested) > 3) { | ||
seq <- 3:(nrow(pd_nested) - 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again. |
||
pd_nested$indention_ref_id[seq] <- pd_nested$id[1] | ||
} | ||
|
@@ -130,5 +130,4 @@ apply_ref_indention_one <- function(flattened_pd, target_token) { | |
flattened_pd$col1[cols_to_update] <- flattened_pd$col1[cols_to_update] + shift | ||
flattened_pd$col2[cols_to_update] <- flattened_pd$col2[cols_to_update] + shift | ||
flattened_pd | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,18 +66,18 @@ set_line_break_after_opening_if_call_is_multi_line <- | |
function(pd, | ||
except_token_after = NULL, | ||
except_text_before = NULL) { | ||
if (!is_function_call(pd)) return(pd) | ||
npd <- nrow(pd) | ||
is_multi_line <- any(pd$lag_newlines[seq2(3, npd - 1)] > 0) | ||
if (!is_multi_line) return(pd) | ||
exception_pos <- c( | ||
which(pd$token %in% except_token_after), | ||
ifelse(pd$child[[1]]$text[1] %in% except_text_before, 3L, NA) | ||
) | ||
pd$lag_newlines[3] <- 0L | ||
pd$lag_newlines[setdiff(3, exception_pos)] <- 1L | ||
pd | ||
} | ||
if (!is_function_call(pd)) return(pd) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indention desired if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See line 66. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, but we can postpone. For now, maybe move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the problem is that the function name is so long that it does not all fit on one line... |
||
npd <- nrow(pd) | ||
is_multi_line <- any(pd$lag_newlines[seq2(3, npd - 1)] > 0) | ||
if (!is_multi_line) return(pd) | ||
exception_pos <- c( | ||
which(pd$token %in% except_token_after), | ||
ifelse(pd$child[[1]]$text[1] %in% except_text_before, 3L, NA) | ||
) | ||
pd$lag_newlines[3] <- 0L | ||
pd$lag_newlines[setdiff(3, exception_pos)] <- 1L | ||
pd | ||
} | ||
|
||
|
||
#' @describeIn set_line_break_if_call_is_multi_line Sets line break before | ||
|
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.
@krlmlr desired?
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.
Looks good to me.