Description
It is great to have a restore session upon loading (though I am still trying to make it work 🤣 but that's on me...).
I have a question though: why decoupling the write_current_state
from the other save_state
function? i.e., I could expect that the periodic save would take care of the write_current_state because that's the closest thing to complement a restore upon restart. Also, I'm not super clear why the write_current_state requires a type
parameter when the documentation indicates that it expects a workspace
?
Going a bit deeper, it is clear that the example give to act on event would require to add
-- Write the current state when it has been selected
wezterm.on("smart_workspace_switcher.workspace_switcher.chosen", function(window, workspace, label)
resurrect.write_current_state(label, "workspace")
end)
to complement the
-- Saves the state whenever I select a workspace
wezterm.on("smart_workspace_switcher.workspace_switcher.selected", function(window, path, label)
local workspace_state = resurrect.workspace_state
resurrect.save_state(workspace_state.get_workspace_state())
end)
As well when creating a new workspace, it should be modified with
-- Load the state whenever I create a new workspace
wezterm.on("smart_workspace_switcher.workspace_switcher.created", function(window, path, label)
local workspace_state = resurrect.workspace_state
workspace_state.restore_workspace(resurrect.load_state(label, "workspace"), {
window = window,
relative = true,
restore_text = true,
on_pane_restore = resurrect.tab_state.default_on_pane_restore,
})
resurrect.write_current_state(label, "workspace")
end)
Do let me know if I'm wrong please, it'll help me getting my understanding right.