From 4a6edc3349a2a9850075363965d05b9063817df4 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Sat, 16 Nov 2024 13:46:45 +0800 Subject: [PATCH] fix: use `args` instead of `self` for fetchers --- git.yazi/init.lua | 11 +++++++---- mactag.yazi/init.lua | 7 +++++-- mime-ext.yazi/init.lua | 11 +++++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/git.yazi/init.lua b/git.yazi/init.lua index 3cf79a8..e262674 100644 --- a/git.yazi/init.lua +++ b/git.yazi/init.lua @@ -154,8 +154,11 @@ local function setup(st, opts) end, opts.order) end -local function fetch(self) - local cwd = self.files[1].url:parent() +local function fetch(self, args) + -- TODO: remove this once Yazi 0.4 is released + args = args or self + + local cwd = args.files[1].url:parent() local repo = root(cwd) if not repo then remove(tostring(cwd)) @@ -163,7 +166,7 @@ local function fetch(self) end local paths = {} - for _, f in ipairs(self.files) do + for _, f in ipairs(args.files) do paths[#paths + 1] = tostring(f.url) end @@ -189,7 +192,7 @@ local function fetch(self) end end - if self.files[1].cha.is_dir then + if args.files[1].cha.is_dir then ya.dict_merge(changed, bubble_up(changed)) ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo))) else diff --git a/mactag.yazi/init.lua b/mactag.yazi/init.lua index b735073..c2f2d8b 100644 --- a/mactag.yazi/init.lua +++ b/mactag.yazi/init.lua @@ -35,9 +35,12 @@ local function setup(st, opts) end, 500) end -local function fetch(self) +local function fetch(self, args) + -- TODO: remove this once Yazi 0.4 is released + args = args or self + local paths = {} - for _, file in ipairs(self.files) do + for _, file in ipairs(args.files) do paths[#paths + 1] = tostring(file.url) end diff --git a/mime-ext.yazi/init.lua b/mime-ext.yazi/init.lua index 3b6ad78..c479bf0 100644 --- a/mime-ext.yazi/init.lua +++ b/mime-ext.yazi/init.lua @@ -1051,13 +1051,16 @@ function M:setup(opts) self.fallback_file1 = opts.fallback_file1 end -function M:fetch() +function M:fetch(args) + -- TODO: remove this once Yazi 0.4 is released + args = args 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 {}) local updates, unknown = {}, {} - for _, file in ipairs(self.files) do + for _, file in ipairs(args.files) do local mime if file.cha.len == 0 then mime = "inode/x-empty" @@ -1079,8 +1082,8 @@ function M:fetch() end if #unknown > 0 then - self.files = unknown - return require("mime").fetch(self) + args.files = unknown + return require("mime").fetch(args) end return 1