From 2a8a8100fef8865da2b43c4d40924a08b1b67c75 Mon Sep 17 00:00:00 2001 From: tiendo1011 Date: Tue, 14 Dec 2021 15:56:17 +0700 Subject: [PATCH] Correct last index position --- lib/diff/lcs/internals.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/diff/lcs/internals.rb b/lib/diff/lcs/internals.rb index 60027f2..4977288 100644 --- a/lib/diff/lcs/internals.rb +++ b/lib/diff/lcs/internals.rb @@ -253,7 +253,7 @@ def replace_next_larger(enum, value, last_index = nil) end # Binary search for the insertion point - last_index ||= enum.size + last_index ||= enum.size - 1 first_index = 0 while first_index <= last_index i = (first_index + last_index) >> 1