From f1972bdee0489abc3a2c13e45309dfdc589e3f9a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 21 Feb 2024 15:21:58 +0300 Subject: [PATCH 1/2] fix(utilities): Fix broken breadcrumbs:contains() --- core/utilities.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/utilities.lua b/core/utilities.lua index 92752ce85..f0c77cf32 100644 --- a/core/utilities.lua +++ b/core/utilities.lua @@ -617,8 +617,9 @@ utilities.breadcrumbs = function () end function breadcrumbs:contains (needle) - for i, command in ipairs(self) do - if command == needle then return true, #self - i end + for i = 0, #SILE.traceStack - 1 do + local frame = SILE.traceStack[#SILE.traceStack-i] + if frame.command == needle then return true, #self - i end end return false, -1 end From 64e8d3bb318a4c4f1553a0b233c2b7f09add2096 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 21 Feb 2024 15:36:57 +0300 Subject: [PATCH 2/2] feat(utilities): Make it easier to search breadcrumbs excluding the current command --- core/utilities.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/utilities.lua b/core/utilities.lua index f0c77cf32..8703530af 100644 --- a/core/utilities.lua +++ b/core/utilities.lua @@ -616,8 +616,9 @@ utilities.breadcrumbs = function () return self[#SILE.traceStack-(count or 1)] end - function breadcrumbs:contains (needle) - for i = 0, #SILE.traceStack - 1 do + function breadcrumbs:contains (needle, startdepth) + startdepth = startdepth or 0 + for i = startdepth, #SILE.traceStack - 1 do local frame = SILE.traceStack[#SILE.traceStack-i] if frame.command == needle then return true, #self - i end end