Skip to content

Commit f1bdf77

Browse files
styling on character(0) does return warning instead of random error
1 parent e69ced6 commit f1bdf77

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

R/transform.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ make_transformer <- function(transformers) {
8383
#' @inheritParams compute_parse_data_nested
8484
#' @inheritParams apply_transformers
8585
parse_transform_serialize <- function(text, transformers) {
86+
text <- assert_text(text)
8687
pd_nested <- compute_parse_data_nested(text)
8788
start_line <- find_start_line(pd_nested)
8889
if (nrow(pd_nested) == 0) {

R/utils.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@ calls_sys <- function(sys_call, ...) {
3939
error <- system(sys_call, ...)
4040
}
4141
}
42+
43+
#' Assert text to be of positive length and replace it with the empty
44+
#' string otherwise.
45+
#' @param text The input to style.
46+
assert_text <- function(text) {
47+
if (length(text) < 1) {
48+
text <- ""
49+
}
50+
text
51+
}

man/assert_text.Rd

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)