From 6b143c1f4d9b0531643b25025daf94d59baf8dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20misaki=20masa?= Date: Tue, 31 Mar 2026 22:13:14 +0800 Subject: [PATCH] fix: enable sysfs files in the preset `empty` previewer (#3833) --- yazi-plugin/preset/plugins/empty.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yazi-plugin/preset/plugins/empty.lua b/yazi-plugin/preset/plugins/empty.lua index 105b4b62..6805b47b 100644 --- a/yazi-plugin/preset/plugins/empty.lua +++ b/yazi-plugin/preset/plugins/empty.lua @@ -3,11 +3,12 @@ local M = {} function M.msg(job, s) ya.preview_widget(job, ui.Text(ui.Line(s):reverse()):area(job.area):wrap(ui.Wrap.YES)) end function M:peek(job) - if not job.file.url:starts_with("/proc/") then + local url = job.file.url + if not url:starts_with("/sys/") and not url:starts_with("/proc/") then return self.msg(job, "Empty file") end - local fd, err = fs.access():read(true):open(job.file.url) + local fd, err = fs.access():read(true):open(url) if not fd then return self.msg(job, "Failed to open file: " .. err) end @@ -20,7 +21,7 @@ function M:peek(job) elseif lines.n == 0 then self.msg(job, "Empty file") elseif job.skip > 0 and lines.n < job.skip + job.area.h then - ya.emit("peek", { math.max(0, lines.n - job.area.h), only_if = job.file.url, upper_bound = true }) + ya.emit("peek", { math.max(0, lines.n - job.area.h), only_if = url, upper_bound = true }) else ya.preview_widget(job, ui.Text(lines):area(job.area)) end