Skip to content

Commit

Permalink
refactor: remove compatibility code for Yazi 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Dec 23, 2024
1 parent f131710 commit c7feb90
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 43 deletions.
5 changes: 1 addition & 4 deletions git.yazi/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 1 addition & 17 deletions lsar.yazi/init.lua
Original file line number Diff line number Diff line change
@@ -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))
Expand Down Expand Up @@ -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
12 changes: 3 additions & 9 deletions mactag.yazi/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down
7 changes: 1 addition & 6 deletions mime-ext.yazi/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 {})
Expand All @@ -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
Expand Down
8 changes: 1 addition & 7 deletions no-status.yazi/init.lua
Original file line number Diff line number Diff line change
@@ -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, ...)
Expand Down

0 comments on commit c7feb90

Please sign in to comment.