From db345a5283a54031c5e9746020597c6282977c79 Mon Sep 17 00:00:00 2001 From: Frank <472730949@qq.com> Date: Wed, 13 Nov 2019 11:29:54 +0800 Subject: [PATCH] Get rid of self from importing others function --- Baggins-Options.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Baggins-Options.lua b/Baggins-Options.lua index 7bff982..7e40cf9 100644 --- a/Baggins-Options.lua +++ b/Baggins-Options.lua @@ -2947,6 +2947,8 @@ local function newSection(info) end function Baggins:CopyBag(from_id, to_id) + if from_id == to_id then return end + local bags = self.db.profile.bags for i, v in ipairs(bags[from_id].sections) do @@ -2957,10 +2959,12 @@ function Baggins:CopyBag(from_id, to_id) end local bags_list = { } -local function ListBags() +local function ListBagsExcept(bagid) wipe(bags_list) for id, bag in ipairs(Baggins.db.profile.bags) do - bags_list[id] = bag.name + if id ~= bagid then + bags_list[id] = bag.name + end end return bags_list end @@ -3116,7 +3120,9 @@ function Baggins:RebuildBagOptions() desc = L["New Bag"], func = newBag, } + for bagid, bag in ipairs(bags) do + local bagListExceptSelected = ListBagsExcept(bagid) local bagconfig = { name = getArgName, desc = getArgName, @@ -3178,7 +3184,7 @@ function Baggins:RebuildBagOptions() desc = "", type = 'select', set = CopyBagFromEdit, - values = ListBags, + values = bagListExceptSelected, arg = bagid, order = 6, },