Skip to content

Commit 5cc51d1

Browse files
fix bug from sorting
1 parent df3608d commit 5cc51d1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

R/highlight_test_str.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ highlight_test_str = function(str, pattern, ignore_case = TRUE,
124124
# modifying string in place using indices
125125
# work back to front to avoid disrupting indices
126126
match_df = data.table::data.table(match_df)
127-
match_df = match_df[order(match_ind, capture_start, decreasing = TRUE), ]
127+
match_df = match_df[order(match_ind, decreasing = TRUE), ]
128128
} else {
129129
match_end = matches_raw + attr(matches_raw, "match.length") - 1
130130

tests/testthat/test-highlight_test_str.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ test_that("highlight_test_str basic", {
1414
})
1515

1616

17+
test_that("welcome screen example", {
18+
test_result = regexTestR:::highlight_test_str("This is a test string for testing regex.", "t(es)(t)")
19+
expected = paste0(
20+
"This is a <span style='background-color:#8DD3C7'>t",
21+
"<span style='background-color:#FFFFB3'>es</span>",
22+
"<span style='background-color:#BEBADA'>t</span></span>",
23+
" string for <span style='background-color:#8DD3C7'>t",
24+
"<span style='background-color:#FFFFB3'>es</span>",
25+
"<span style='background-color:#BEBADA'>t</span></span>ing regex."
26+
)
27+
28+
expect_equal(test_result, expected)
29+
})
30+
31+
1732
test_that("highlight_test_str perl = FALSE", {
1833
test_result = regexTestR:::highlight_test_str("abc aaa", "a(..)", perl = FALSE)
1934
expected = paste0(

0 commit comments

Comments
 (0)