Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# stringr 1.3.1.9000

* `str_interp()` now renders lists consistently independent on the presence of
additional placeholders (@amhrasmussen)

# stringr 1.3.1

* `str_replace_all()` with a named vector now respects modifier functions (#207)
Expand Down
2 changes: 1 addition & 1 deletion R/interp.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ eval_interp_matches <- function(matches, env) {
formats <- extract_formats(matches)

# Format the values and return.
mapply(sprintf, formats, values)
mapply(sprintf, formats, values, SIMPLIFY = FALSE)
}

#' Extract Expression Objects from String Interpolation Matches
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-interp.r
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ test_that("str_interp fails when encountering nested placeholders", {
test_that("str_interp fails when input is not a character string", {
expect_error(str_interp(3L))
})

test_that("str_interp formats list independetly of other placeholders", {
a_list <- c("item1", "item2", "item3")
other <- "1"
extract <- function(text) regmatches(text, regexpr("xx[^x]+xx", text))
from_list <- extract(str_interp("list: xx${a_list}xx"))
from_both <- extract(str_interp("list: xx${a_list}xx, and another ${other}"))
expect_equal(from_list, from_both)
})