mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: reversed style shouldn't be applied to the entire text block
This commit is contained in:
parent
2a4a398342
commit
d754ac5dac
3 changed files with 13 additions and 12 deletions
|
|
@ -6,12 +6,11 @@ function M:peek(job)
|
||||||
|
|
||||||
local files, bound, code = self.list_files({ "-p", tostring(job.file.url) }, job.skip, limit)
|
local files, bound, code = self.list_files({ "-p", tostring(job.file.url) }, job.skip, limit)
|
||||||
if code ~= 0 then
|
if code ~= 0 then
|
||||||
return ya.preview_widgets(job, {
|
return require("empty").msg(
|
||||||
ui.Text(
|
job,
|
||||||
code == 2 and "File list in this archive is encrypted"
|
code == 2 and "File list in this archive is encrypted"
|
||||||
or "Failed to start both `7z` and `7zz`. Do you have 7-zip installed?"
|
or "Failed to start both `7z` and `7zz`. Do you have 7-zip installed?"
|
||||||
):area(job.area),
|
)
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, f in ipairs(files) do
|
for _, f in ipairs(files) do
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ function M:peek(job)
|
||||||
if bound then
|
if bound then
|
||||||
ya.manager_emit("peek", { bound, only_if = job.file.url, upper_bound = true })
|
ya.manager_emit("peek", { bound, only_if = job.file.url, upper_bound = true })
|
||||||
elseif err and not err:find("cancelled", 1, true) then
|
elseif err and not err:find("cancelled", 1, true) then
|
||||||
ya.preview_widgets(job, {
|
require("empty").msg(job, err)
|
||||||
ui.Text(err):area(job.area):reverse(),
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
local M = {}
|
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)
|
function M:peek(job)
|
||||||
local path = tostring(job.file.url)
|
local path = tostring(job.file.url)
|
||||||
if path:sub(1, 6) ~= "/proc/" then
|
if path:sub(1, 6) ~= "/proc/" then
|
||||||
return self:msg(job, "Empty file")
|
return self.msg(job, "Empty file")
|
||||||
end
|
end
|
||||||
|
|
||||||
local limit = job.area.h
|
local limit = job.area.h
|
||||||
|
|
@ -22,7 +26,7 @@ function M:peek(job)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not ok then
|
if not ok then
|
||||||
self:msg(job, err)
|
self.msg(job, err)
|
||||||
elseif job.skip > 0 and i < job.skip + limit then
|
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 })
|
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue