refactor: remove compatibility code for Yazi 0.3

This commit is contained in:
sxyazi
2024-12-23 15:29:59 +08:00
parent f1317106ab
commit c7feb90930
5 changed files with 7 additions and 43 deletions

View File

@@ -154,10 +154,7 @@ local function setup(st, opts)
end, opts.order)
end
local function fetch(self, job)
-- TODO: remove this once Yazi 0.4 is released
job = job or self
local function fetch(_, job)
local cwd = job.files[1].url:parent()
local repo = root(cwd)
if not repo then

View File

@@ -1,9 +1,6 @@
local M = {}
function M:peek(job)
-- TODO: remove this once Yazi 0.4 is released
job = job or self
local child, code = Command("lsar"):arg(tostring(job.file.url)):stdout(Command.PIPED):spawn()
if not child then
return ya.err("spawn `lsar` command returns " .. tostring(code))
@@ -39,19 +36,6 @@ function M:peek(job)
end
end
function M:seek(job)
-- TODO: remove this once Yazi 0.4 is released
local units = type(job) == "table" and job.units or job
job = type(job) == "table" and job or self
local h = cx.active.current.hovered
if h and h.url == job.file.url then
local step = math.floor(units * job.area.h / 10)
ya.manager_emit("peek", {
math.max(0, cx.active.preview.skip + step),
only_if = job.file.url,
})
end
end
function M:seek(job) require("code"):seek(job) end
return M

View File

@@ -35,10 +35,7 @@ local function setup(st, opts)
end, 500)
end
local function fetch(self, job)
-- TODO: remove this once Yazi 0.4 is released
job = job or self
local function fetch(_, job)
local paths = {}
for _, file in ipairs(job.files) do
paths[#paths + 1] = tostring(file.url)
@@ -76,10 +73,7 @@ local cands = ya.sync(function(st)
end)
local function entry(self, job)
-- TODO: remove this once Yazi 0.4 is released
local args = job.args or job
assert(args[1] == "add" or args[1] == "remove", "Invalid action")
assert(job.args[1] == "add" or job.args[1] == "remove", "Invalid action")
ya.manager_emit("escape", { visual = true })
local cands = cands()
@@ -88,7 +82,7 @@ local function entry(self, job)
return
end
local t = { args[1] == "remove" and "-r" or "-a", cands[choice].desc }
local t = { job.args[1] == "remove" and "-r" or "-a", cands[choice].desc }
local files = {}
for _, url in ipairs(selected_or_hovered()) do
t[#t + 1] = tostring(url)

View File

@@ -1060,10 +1060,6 @@ function M:setup(opts)
end
function M:fetch(job)
-- TODO: remove this once Yazi 0.4 is released
local not_v4 = not job
job = job or self
local opts = options()
local merged_files = ya.dict_merge(FILES, opts.with_files or {})
local merged_exts = ya.dict_merge(EXTS, opts.with_exts or {})
@@ -1089,12 +1085,11 @@ function M:fetch(job)
if next(updates) then
ya.manager_emit("update_mimes", { updates = updates })
ya.manager_emit("update_mimetype", { updates = updates }) -- TODO: remove this
end
if #unknown > 0 then
job.files = unknown
return not_v4 and require("mime").fetch(job) or require("mime"):fetch(job)
return require("mime"):fetch(job)
end
return 1

View File

@@ -1,13 +1,7 @@
local function setup()
local old_layout = Tab.layout
-- TODO: remove this check once v0.4 is released
if Status.redraw then
Status.redraw = function() return {} end
else
Status.render = function() return {} end
end
Status.redraw = function() return {} end
Tab.layout = function(self, ...)
self._area = ui.Rect { x = self._area.x, y = self._area.y, w = self._area.w, h = self._area.h + 1 }
return old_layout(self, ...)