From 0cc08ff142621dac444d84be05bf9b6f4acd602b Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 6 Feb 2026 17:43:10 -0800 Subject: allow teleporting back after a goto --- rt.lua | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'rt.lua') diff --git a/rt.lua b/rt.lua index 73b5b9d..f5a47ac 100644 --- a/rt.lua +++ b/rt.lua @@ -578,7 +578,7 @@ function rt.open_option_info(opt) end end -local function goto_path(path, opt, reverse) +local function goto_path_traverse(path, opt, reverse) local start, stop, step = 1, #path, 1 if reverse then start, stop, step = stop, start, -1 @@ -596,6 +596,14 @@ local function goto_path(path, opt, reverse) cursor_to_id(opt.id) end +local function goto_path(d, ...) + local origin = state:capture_origin(d) + state.depth = d + goto_path_traverse(...) + state:menu().origin = origin + osd:dirty() +end + function rt.goto_option() local menu = state:menu() local opt = menu.options[menu.cursor] @@ -603,17 +611,17 @@ function rt.goto_option() return end + local d = state.depth if menu.group_id == 'favourites' then - state.depth = 1 + d = 1 elseif menu.type == 'search' then - state.depth = state.depth - 1 - if state:menu().group_id == 'favourites' then - merge_refreshed_menu_options() - end + d = d - 1 end - goto_path(opt.path, opt) - osd:dirty() + goto_path(d, opt.path, opt) + if state:menu().group_id == 'favourites' then + merge_refreshed_menu_options() + end end function rt.goto_playing() @@ -624,8 +632,21 @@ function rt.goto_playing() return end - state.depth = 1 - goto_path(path, opt, true) + goto_path(1, path, opt, true) +end + +function rt.goto_origin() + local menu = state:menu() + local origin = menu.origin + if not origin then + return + end + + menu.origin = nil + state:restore_origin(origin) + if state:menu().group_id == 'favourites' then + merge_refreshed_menu_options() + end osd:dirty() end -- cgit v1.2.3-70-g09d2