aboutsummaryrefslogtreecommitdiffstats
path: root/macros/garret.dupe-and-comment.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2022-12-24 16:00:13 +0000
committergarret <garret@airmail.cc>2022-12-24 16:00:13 +0000
commit5d3c4f0e6c60aec90540de4a32594122ab9e799e (patch)
tree9c42acca92211786eb4fea3b36b46454a566214a /macros/garret.dupe-and-comment.lua
parent6a42bab6681b45ae5914eb66ec8f46057118e358 (diff)
downloadaegisub-scripts-5d3c4f0e6c60aec90540de4a32594122ab9e799e.tar.gz
aegisub-scripts-5d3c4f0e6c60aec90540de4a32594122ab9e799e.tar.bz2
aegisub-scripts-5d3c4f0e6c60aec90540de4a32594122ab9e799e.zip
dupe and comment: fix out of range error in undo
Diffstat (limited to 'macros/garret.dupe-and-comment.lua')
-rw-r--r--macros/garret.dupe-and-comment.lua14
1 files changed, 8 insertions, 6 deletions
diff --git a/macros/garret.dupe-and-comment.lua b/macros/garret.dupe-and-comment.lua
index c445bfb..a434712 100644
--- a/macros/garret.dupe-and-comment.lua
+++ b/macros/garret.dupe-and-comment.lua
@@ -1,7 +1,7 @@
script_name="Dupe and Comment"
script_description="Copies a line and comments out the original.\nbecause i like seeing the original while editing, and being able to go back to it easily"
script_author = "garret"
-script_version = "2.1.2"
+script_version = "2.1.3"
script_namespace = "garret.dupe-and-comment"
local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl")
@@ -30,11 +30,13 @@ end
local function undo(subs, sel)
for i=#sel,1,-1 do
local edit=subs[sel[i]]
- local original=subs[sel[i]+1]
- if edit.comment == false and original.comment == true then
- original.comment = false
- subs[sel[i]+1] = original
- subs.delete(sel[i])
+ if not (sel[i] + 1 > #subs) then
+ local original=subs[sel[i]+1]
+ if edit.comment == false and original.comment == true then
+ original.comment = false
+ subs[sel[i]+1] = original
+ subs.delete(sel[i])
+ end
end
end
aegisub.set_undo_point("Undo "..script_name)