diffviewer icon indicating copy to clipboard operation
diffviewer copied to clipboard

`visual_diff()` stalls for large diffs

Open wurli opened this issue 1 year ago • 0 comments

Ported from https://github.com/r-lib/testthat/issues/1990.

Really, if anyone's using such large snapshots it's arguable that they're the problem. That said, it would be nice if the shiny app used by snapshot_review() could make some concession for very large diffs, even if that just meant failing gracefully. Ideally some kind of pagination might be an alternative solution.

Here's a reprex. For me it takes around 1,000,000 lines before things become truly unusable.

text_a <- sample(c(stringr::words), 1000000, replace = TRUE) |> paste(collapse = "\n")
text_b <- gsub("ab", "cd", text_a)

path_a <- tempfile("text_a", fileext = ".txt")
path_b <- tempfile("text_b", fileext = ".txt")

writeLines(text_a, path_a)
writeLines(text_b, path_b)

diffviewer::visual_diff(path_a, path_b)

I'll hopefully be able to open a PR at some point to fix this, but no promises 😄

wurli avatar Oct 24 '24 16:10 wurli