Skip to content

Commit

Permalink
continuing regression fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brodieG committed Aug 1, 2016
1 parent 5327672 commit 9bc590b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions R/core.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ line_diff <- function(
# Word diffs in wrapped form is atomic; note this will potentially change
# the length of the vectors

tar.wrap.diff <- integer(0L)
cur.wrap.diff <- integer(0L)

if(
is.atomic(target) && is.atomic(current) &&
length(tar.rh <- which_atomic_cont(tar.capt.p, target)) &&
Expand Down Expand Up @@ -383,6 +386,12 @@ line_diff <- function(
Map(dat.up, tar.dat, diff.word$tar.dat, MoreArgs=list(ind=tar.rh))
cur.dat <-
Map(dat.up, cur.dat, diff.word$cur.dat, MoreArgs=list(ind=cur.rh))

# Mark the lines that were wrapped diffed; necessary b/c tar/cur.rh are
# defined even if other conditions to get in this loop are not

tar.wrap.diff <- tar.rh
cur.wrap.diff <- cur.rh
}
# Actual line diff

Expand All @@ -398,17 +407,14 @@ line_diff <- function(
# diff data for each hunk, which might be slow

if(etc@word.diff) {
# Word diffs on hunks; check first which lines already have diffs and
# exclude them from the diff

tar.l.w.d <- which(vapply(tar.dat$word.ind, "[", integer(1L), 1L) != -1L)
cur.l.w.d <- which(vapply(cur.dat$word.ind, "[", integer(1L), 1L) != -1L)
# Word diffs on hunks, excluding all values that have already been wrap
# diffed as in tar.rh and cur.rh

for(h.a in hunks.flat) {
if(h.a$context) next
h.a.ind <- c(h.a$A, h.a$B)
h.a.tar.ind <- setdiff(h.a.ind[h.a.ind > 0], tar.l.w.d)
h.a.cur.ind <- setdiff(abs(h.a.ind[h.a.ind < 0]), cur.l.w.d)
h.a.tar.ind <- setdiff(h.a.ind[h.a.ind > 0], tar.wrap.diff)
h.a.cur.ind <- setdiff(abs(h.a.ind[h.a.ind < 0]), cur.wrap.diff)
h.a.w.d <- diff_word2(
tar.dat, cur.dat, h.a.tar.ind, h.a.cur.ind, diff.mode="hunk", warn=warn,
etc=etc
Expand Down
Binary file modified tests/testthat/helper/diffPrint/3200.rds
Binary file not shown.

0 comments on commit 9bc590b

Please sign in to comment.