Skip to content

Commit

Permalink
Issue #690: bug fix on kind=hard and notUserA
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Oct 3, 2024
1 parent e6bfd0e commit b343079
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/MRC.lua
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,16 @@ end
local function l_check_user_groups(resultT)
local usrFlg = resultT.userT and resultT.userT[myConfig("username")]
local grpFlg = resultT.groupT and l_intersection(myConfig("usergroups"),resultT.groupT)
local nUsrFlg = resultT.notuserT and resultT.notuserT[myConfig("username")]
local nGrpFlg = resultT.notgroupT and l_intersection(myConfig("usergroups"),resultT.notgroupT)
local nUsrFlg = resultT.notUserT and resultT.notUserT[myConfig("username")]
local nGrpFlg = resultT.notGroupT and l_intersection(myConfig("usergroups"),resultT.notGroupT)

local flag = (usrFlg or grpFlg) or (not (resultT.userT or resultT.groupT) and
local flag = (usrFlg or grpFlg) or (not (resultT.userT or resultT.groupT) and
not (nUsrFlg or nGrpFlg))

--dbg.print{"l_check_user_groups: usrFlg: ",usrFlg,", nUsrFlg: ",nUsrFlg,"\n"}
--dbg.print{" flag: ",flag,"\n"}


return flag
end

Expand Down Expand Up @@ -633,9 +638,10 @@ local function l_check_hidden_modifiers(fullName, resultT, visibleT, show_hidden
local hide_active = (l_check_time_range(resultT, 0) == "inRange" and
l_check_user_groups(resultT))


if (not hide_active) then
-- isVisible, hidden_loaded, kind, count
dbg.fini("l_check_hidden_modifiers")
-- isVisible, hidden_loaded, kind, count
return true, false, "normal", true
end
local isVisible
Expand All @@ -647,8 +653,8 @@ local function l_check_hidden_modifiers(fullName, resultT, visibleT, show_hidden
end


dbg.print{"fullName: ",fullName,", resultT.kind: ", resultT.kind, ", count: ",count,"\n"}
dbg.fini("l_check_hidden_modifiers")
--dbg.print{"fullName: ",fullName,", resultT.kind: ", resultT.kind, ", count: ",count,"\n"}
--dbg.fini("l_check_hidden_modifiers")
return isVisible, resultT.hidden_loaded, resultT.kind, count
end

Expand Down Expand Up @@ -677,10 +683,12 @@ function M.isVisible(self, modT)
-- hidden_loaded = true|nil, }
-- if hidden.


------------------------------------------------------------
-- If sn is already in the ModuleTable then use MT data instead

dbg.print{"fullName: ",fullName,"\n"}

if (mt:exists(sn,fullName)) then
local moduleKindT = mt:moduleKindT(sn)
if (not moduleKindT) then
Expand All @@ -690,12 +698,12 @@ function M.isVisible(self, modT)
end
--dbg.print{"fullName: ",fullName,"\n"}
--dbg.printT("mt:exists(sn): true, my_resultT",my_resultT)
dbg.fini("MRC:isVisible")
dbg.fini("(1) MRC:isVisible")
return my_resultT
end


local resultT = l_findHiddenState(self, mpathA, sn, fullName, fn)
local resultT = l_findHiddenState(self, mpathA, sn, fullName, fn)
if (type(resultT) == "table" ) then
--dbg.printT("from hidden State resultT",resultT)
isVisible, hidden_loaded, kind, count = l_check_hidden_modifiers(fullName, resultT, visibleT, show_hidden)
Expand All @@ -707,7 +715,7 @@ function M.isVisible(self, modT)
local idx = fullName:find("/%.")
isVisible = (idx == nil) or (visibleT.hidden == true) or show_hidden
kind = (idx == nil) and "normal" or "hidden"
count = show_hidden or (idx == nil)
count = show_hidden or (idx == nil)
end

modT.isVisible = isVisible
Expand All @@ -718,12 +726,12 @@ function M.isVisible(self, modT)
hook.apply("isVisibleHook", modT)

my_resultT = { isVisible = modT.isVisible,
moduleKindT = {kind=modT.kind, hidden_loaded = modT.hidden_loaded},
moduleKindT = {kind=modT.kind, hidden_loaded = modT.hidden_loaded},
count = count }

--dbg.print{"fullName: ",fullName,", isVisible: ",isVisible,", kind: ",kind,", show_hidden: ", show_hidden,", count: ",count,", hidden_loaded: ",hidden_loaded,"\n"}
--dbg.printT("my_resultT",my_resultT)
dbg.fini("MRC:isVisible")
dbg.fini("(2) MRC:isVisible")
return my_resultT
end

Expand All @@ -736,7 +744,7 @@ function M.isForbidden(self, modT)
local fullName = modT.fullName
local fn = modT.fn
local sn = modT.sn
local resultT = l_findForbiddenState(self, mpathA, sn, fullName, fn)
local resultT = l_findForbiddenState(self, mpathA, sn, fullName, fn)

--dbg.print{"fullName: ",fullName,"\n"}
--dbg.printT("resultT",resultT)
Expand All @@ -745,7 +753,7 @@ function M.isForbidden(self, modT)
--dbg.fini("MRC:isForbidden")
return nil
end

local forbiddenState = l_check_forbidden_modifiers(fullName, resultT)

modT.forbiddenState = forbiddenState
Expand Down Expand Up @@ -790,7 +798,7 @@ function M.find_wght_for_fullName(self, fullName, wV)
dbg.fini("MRC:find_wght_for_fullName: no fullName")
return wV
end


-- split fullName into an array on '/' --> fnA
local fnA = {}
Expand Down Expand Up @@ -821,7 +829,7 @@ function M.find_wght_for_fullName(self, fullName, wV)
return wV
end

local weight = t.weight
local weight = t.weight
local idx = wV:match("^.*()/")
if (weight) then
if (idx) then
Expand All @@ -830,7 +838,7 @@ function M.find_wght_for_fullName(self, fullName, wV)
wV = weight .. wV:sub(2,-1)
end
end

dbg.print{"found weight: ",weight,", wV: ",wV,"\n"}
dbg.fini("MRC:find_wght_for_fullName")
return wV
Expand Down

0 comments on commit b343079

Please sign in to comment.