aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macros/garret.dupe-and-comment.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/macros/garret.dupe-and-comment.lua b/macros/garret.dupe-and-comment.lua
index 4b3c2d6..198a905 100644
--- a/macros/garret.dupe-and-comment.lua
+++ b/macros/garret.dupe-and-comment.lua
@@ -19,13 +19,14 @@ local function comment(subs, sel, act)
line.comment = true -- comment out the new dupe line
subs.insert(sel[i]+1, line) -- and put it below
- -- sort out sel/act
- local preceding_lines = i - 1
- local on_act = act == sel[i]
-
- sel[i] = sel[i] + preceding_lines
- if on_act then act = sel[i] end
+-- if #sel > 1 then
+ -- sort out sel/act
+ local preceding_lines = i - 1
+ local on_act = act == sel[i]
+ sel[i] = sel[i] + preceding_lines
+ if on_act then act = sel[i] end
+-- end
end
aegisub.set_undo_point(script_name)
return sel, act
@@ -42,12 +43,14 @@ local function undo(subs, sel, act)
subs[sel[i]+1] = original
subs.delete(sel[i])
+ if #sel > 1 then
-- sort out selection. same as `do`, but the other way round.
local preceding_lines = i + 1
local on_act = act == sel[i]
- sel[i] = sel[i] - following_lines
+ sel[i] = sel[i] - preceding_lines
if on_act then act = sel[i] end
+ end
end
end