started working of having '' go to last dir

This commit is contained in:
Diogo Duarte
2024-03-31 15:28:55 +01:00
parent cf259b79f1
commit 914444c097

View File

@@ -43,7 +43,15 @@ local save_bookmark = ya.sync(function(state, idx)
end
end)
local all_bookmarks = ya.sync(function(state) return state.bookmarks or {} end)
local all_bookmarks = ya.sync(function(state, append_last_dir)
bookmarks = state.bookmarks or {}
if append_last_dir and state.last_dir then
table.insert(bookmarks, state.last_dir)
end
return bookmarks
end)
local delete_bookmark = ya.sync(function(state, idx)
if state.notify and state.notify.enable then
@@ -72,6 +80,18 @@ local delete_all_bookmarks = ya.sync(function(state)
end
end)
local _save_last_dir = ya.sync(function(state)
ps.sub("cd", function()
local folder = Folder:by_kind(Folder.CURRENT)
state.last_dir = state.curr_dir
state.curr_dir = {
on = "'",
desc = tostring(folder.cwd),
cursor = folder.cursor,
}
end)
end)
return {
entry = function(_, args)
local action = args[1]
@@ -91,7 +111,7 @@ return {
return delete_all_bookmarks()
end
local bookmarks = all_bookmarks()
local bookmarks = all_bookmarks(action == "jump")
local selected = #bookmarks > 0 and ya.which { cands = bookmarks }
if not selected then
return
@@ -110,6 +130,8 @@ return {
return
end
_save_last_dir()
state.notify = {
enable = false,
timeout = 1,