From 979e2f499af4cce0cecaf1d55ec3685cabedbf01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 9 Feb 2022 12:50:54 +0100 Subject: [PATCH] Fix `format_error()` edge case Closes #394. --- R/format-conditions.R | 2 +- tests/testthat/test-format-conditions.R | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/R/format-conditions.R b/R/format-conditions.R index 57c242108..db5ea6559 100644 --- a/R/format-conditions.R +++ b/R/format-conditions.R @@ -57,7 +57,7 @@ format_error <- function(message, .envir = parent.frame()) { })(), collapse = TRUE, strip_newline = TRUE) # remove "Error: " that was only needed for the wrapping - formatted1[1] <- sub("Error: ", "", formatted1[1]) + formatted1[1] <- sub("Error:[ ]?", "", formatted1[1]) update_rstudio_color(formatted1) } diff --git a/tests/testthat/test-format-conditions.R b/tests/testthat/test-format-conditions.R index aafe51613..4b411613e 100644 --- a/tests/testthat/test-format-conditions.R +++ b/tests/testthat/test-format-conditions.R @@ -165,3 +165,7 @@ test_that_cli("suppressing Unicode bullets", { ))) })) }) + +test_that("edge cases", { + expect_equal(cli::format_error(""), "") +})