Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing an issue with the refactoring done earlier.

  • Loading branch information...
commit 86928fa4a2ca7a91e08571a46a98fdb42aee354d 1 parent 3965b70
Austin Ziegler authored
Showing with 26 additions and 26 deletions.
  1. +1 −1  lib/diff/lcs.rb
  2. +25 −25 lib/diff/lcs/internals.rb
2  lib/diff/lcs.rb
View
@@ -729,7 +729,7 @@ def patch(src, patchset, direction = nil)
# Start with a new empty type of the source's class
res = src.class.new
- direction ||= Diff::LCS.__diff_direction(src, patchset)
+ direction ||= Diff::LCS::Internals.diff_direction(src, patchset)
ai = bj = 0
50 lib/diff/lcs/internals.rb
View
@@ -185,31 +185,6 @@ def diff_direction(src, patchset, limit = nil)
count += 1
case change
- when Diff::LCS::Change
- # With a simplistic change, we can't tell the difference between
- # the left and right on '!' actions, so we ignore those. On '='
- # actions, if there's a miss, we miss both left and right.
- element = string ? src[change.position, 1] : src[change.position]
-
- case change.action
- when '-'
- if element == change.element
- left_match += 1
- else
- left_miss += 1
- end
- when '+'
- if element == change.element
- right_match += 1
- else
- right_miss += 1
- end
- when '='
- if element != change.element
- left_miss += 1
- right_miss += 1
- end
- end
when Diff::LCS::ContextChange
case change.action
when '-' # Remove details from the old string
@@ -247,6 +222,31 @@ def diff_direction(src, patchset, limit = nil)
end
end
end
+ when Diff::LCS::Change
+ # With a simplistic change, we can't tell the difference between
+ # the left and right on '!' actions, so we ignore those. On '='
+ # actions, if there's a miss, we miss both left and right.
+ element = string ? src[change.position, 1] : src[change.position]
+
+ case change.action
+ when '-'
+ if element == change.element
+ left_match += 1
+ else
+ left_miss += 1
+ end
+ when '+'
+ if element == change.element
+ right_match += 1
+ else
+ right_miss += 1
+ end
+ when '='
+ if element != change.element
+ left_miss += 1
+ right_miss += 1
+ end
+ end
end
break if (not limit.nil?) && (count > limit)
Please sign in to comment.
Something went wrong with that request. Please try again.