Skip to content

Commit 13b7f32

Browse files
committed
handle code with single call in split_code
1 parent e1254e7 commit 13b7f32

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

R/utils-get_code_dependency.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,10 @@ get_call_breaks <- function(code) {
488488
#' @noRd
489489
split_code <- function(code) {
490490
call_breaks <- get_call_breaks(code)
491-
call_breaks <- call_breaks[order(call_breaks[, "line"], call_breaks[, "col"]), , drop = FALSE]
491+
if (nrow(call_breaks) == 1) {
492+
return(code)
493+
}
494+
call_breaks <- call_breaks[order(call_breaks[, "line"], call_breaks[, "col"]), ]
492495
code_split <- strsplit(code, split = "\n", fixed = TRUE)[[1]]
493496
char_count_lines <- c(0, cumsum(sapply(code_split, nchar, USE.NAMES = FALSE) + 1), -1)[seq_along(code_split)]
494497

0 commit comments

Comments
 (0)