From d85419c49ae4ea75904fa9c7a9355123b44260a5 Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Mon, 15 Apr 2013 15:42:52 -0700
Subject: [PATCH] Select the right things in the select overlaps macro. Closes
 #1594.

---
 aegisub/automation/autoload/select-overlaps.lua | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/aegisub/automation/autoload/select-overlaps.lua b/aegisub/automation/autoload/select-overlaps.lua
index 35bb38bce..f5905c933 100644
--- a/aegisub/automation/autoload/select-overlaps.lua
+++ b/aegisub/automation/autoload/select-overlaps.lua
@@ -27,11 +27,13 @@ function select_overlaps(subs)
     for i = 1,#subs do
         local line = subs[i]
         if line.class == "dialogue" then
-            line.i = i - 1
+            line.i = i
             table.insert(dialogue, line)
         end
     end
-    table.sort(dialogue, function(a,b) return a.start_time < b.start_time end)
+    table.sort(dialogue, function(a,b)
+        return a.start_time < b.start_time or (a.start_time == b.start_time and a.i < b.i)
+    end)
 
     local end_time = 0
     local overlaps = {}
-- 
GitLab