mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: do not block skip to be set of making preview go beyond view, there is a guard already
This commit is contained in:
parent
2bb1c8fb8f
commit
d1a3f7bc54
2 changed files with 7 additions and 8 deletions
|
|
@ -39,11 +39,7 @@ impl Actor for Peek {
|
|||
|
||||
let preview = &mut cx.tab_mut().preview;
|
||||
if let Some(skip) = form.skip {
|
||||
if form.upper_bound {
|
||||
preview.skip = preview.skip.min(skip);
|
||||
} else {
|
||||
preview.skip = skip;
|
||||
}
|
||||
preview.skip = skip;
|
||||
}
|
||||
|
||||
match form.search_idx {
|
||||
|
|
|
|||
|
|
@ -44,8 +44,9 @@ function M:peek(job)
|
|||
if search_idx == nil and search_occurrences then
|
||||
local occurrence = search_occurrences[1]
|
||||
local line = occurrence[1]
|
||||
local skip = math.max(0, line - 1)
|
||||
ya.emit("peek", {
|
||||
math.max(0, line - 1),
|
||||
skip,
|
||||
only_if = job.file.url,
|
||||
search_idx = 1,
|
||||
})
|
||||
|
|
@ -84,16 +85,18 @@ function M:seek(job)
|
|||
local next_occurrence_idx = get_next_occurrence_idx(search_idx, direction, #search_occurrences)
|
||||
local occurrence = search_occurrences[next_occurrence_idx]
|
||||
local line = occurrence[1]
|
||||
local skip = math.max(0, line - 1)
|
||||
|
||||
ya.emit("peek", { math.max(0, line - 1), only_if = job.file.url, search_idx = next_occurrence_idx })
|
||||
ya.emit("peek", { skip, only_if = job.file.url, search_idx = next_occurrence_idx })
|
||||
return
|
||||
end
|
||||
|
||||
local step = math.floor(job.units * job.area.h / 10)
|
||||
step = step == 0 and ya.clamp(-1, job.units, 1) or step
|
||||
local skip = math.max(0, cx.active.preview.skip + step)
|
||||
|
||||
ya.emit("peek", {
|
||||
math.max(0, cx.active.preview.skip + step),
|
||||
skip,
|
||||
only_if = job.file.url,
|
||||
search_idx = search_idx,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue