From 7a1dc3729f0bc3f0d62214683117d490113c3007 Mon Sep 17 00:00:00 2001 From: MasouShizuka Date: Mon, 5 Aug 2024 08:58:52 +0800 Subject: [PATCH] fix: Corrected the reading of array index of dds in yazi v0.3 --- init.lua | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/init.lua b/init.lua index cda327c..01987f8 100644 --- a/init.lua +++ b/init.lua @@ -617,24 +617,18 @@ end) local _load_projects = ya.sync(function(state) if state.save.method == "yazi" then ps.sub_remote("@projects", function(body) - if not state.projects and body then - state.projects = _get_default_projects() - - for _, value in pairs(body.list) do - state.projects.list[#state.projects.list + 1] = value - end - - state.projects.last = body.last - end + state.projects = body end) elseif state.save.method == "lua" then local f = io.open(state.save.lua_save_path, "r") - if not f then - return + if f then + state.projects = json.decode(f:read("*a")) + io.close(f) end - local projects = json.decode(f:read("*a")) or _get_default_projects() - io.close(f) - state.projects = projects + end + + if not state.projects then + state.projects = _get_default_projects() end end) @@ -799,7 +793,7 @@ local _merge_event = ya.sync(function(state) _notify(message) end elseif opt == "current" then - local tab = body.tabs[tostring(body.active_idx)] + local tab = body.tabs[tonumber(body.active_idx)] _merge_tab(tab) if state.notify.enable then