From d8a57993b184e378742947adeef382572775ef80 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 12 May 2025 21:35:51 -0700 Subject: add paths to favourites --- main.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'main.lua') diff --git a/main.lua b/main.lua index d3d2025..681f7bb 100644 --- a/main.lua +++ b/main.lua @@ -53,6 +53,12 @@ local function copy_table(t) return u end +local function reverse(t) + for i = 1, #t/2 do + t[i], t[#t-i+1] = t[#t-i+1], t[i] + end +end + local function strip(str) return (str:gsub('^%s*(.-)%s*$', '%1')) end @@ -387,6 +393,19 @@ local function favourites_group_menu_options(group) for id in pairs(favourites) do local obj = objects[id] if obj then + local path = {} + local curr = obj + while curr.parent_id and curr.parent_id ~= 'root' and + objects[curr.parent_id] do + curr = objects[curr.parent_id] + path[#path+1] = curr + end + if #path > 0 and curr.parent_id == 'root' then + reverse(path) + obj = copy_table(obj) + obj.path = path + end + options[#options+1] = obj end end -- cgit v1.2.3-70-g09d2