fix: reversed style shouldn't be applied to the entire text block

This commit is contained in:
sxyazi 2024-12-25 23:46:55 +08:00
parent 2a4a398342
commit d754ac5dac
No known key found for this signature in database
3 changed files with 13 additions and 12 deletions

View file

@ -6,12 +6,11 @@ function M:peek(job)
local files, bound, code = self.list_files({ "-p", tostring(job.file.url) }, job.skip, limit)
if code ~= 0 then
return ya.preview_widgets(job, {
ui.Text(
code == 2 and "File list in this archive is encrypted"
or "Failed to start both `7z` and `7zz`. Do you have 7-zip installed?"
):area(job.area),
})
return require("empty").msg(
job,
code == 2 and "File list in this archive is encrypted"
or "Failed to start both `7z` and `7zz`. Do you have 7-zip installed?"
)
end
for _, f in ipairs(files) do

View file

@ -5,9 +5,7 @@ function M:peek(job)
if bound then
ya.manager_emit("peek", { bound, only_if = job.file.url, upper_bound = true })
elseif err and not err:find("cancelled", 1, true) then
ya.preview_widgets(job, {
ui.Text(err):area(job.area):reverse(),
})
require("empty").msg(job, err)
end
end

View file

@ -1,11 +1,15 @@
local M = {}
function M:msg(job, s) ya.preview_widgets(job, { ui.Text(s):area(job.area):reverse():wrap(ui.Text.WRAP) }) end
function M.msg(job, s)
ya.preview_widgets(job, {
ui.Text(ui.Line(s):reverse()):area(job.area):wrap(ui.Text.WRAP),
})
end
function M:peek(job)
local path = tostring(job.file.url)
if path:sub(1, 6) ~= "/proc/" then
return self:msg(job, "Empty file")
return self.msg(job, "Empty file")
end
local limit = job.area.h
@ -22,7 +26,7 @@ function M:peek(job)
end)
if not ok then
self:msg(job, err)
self.msg(job, err)
elseif job.skip > 0 and i < job.skip + limit then
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
else