mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
395c04a852
commit
c4f76bd778
2 changed files with 10 additions and 6 deletions
|
|
@ -19,6 +19,9 @@ keymap = [
|
|||
{ on = [ "H" ], exec = "back" },
|
||||
{ on = [ "L" ], exec = "forward" },
|
||||
|
||||
{ on = [ "<C-k>" ], exec = "peek -5" },
|
||||
{ on = [ "<C-j>" ], exec = "peek 5" },
|
||||
|
||||
{ on = [ "<Up>" ], exec = "arrow -1" },
|
||||
{ on = [ "<Down>" ], exec = "arrow 1" },
|
||||
{ on = [ "<Left>" ], exec = "leave" },
|
||||
|
|
|
|||
|
|
@ -106,27 +106,28 @@ impl Provider {
|
|||
let mut buf = String::new();
|
||||
|
||||
let mut i = 0;
|
||||
let mut limit = MANAGER.layout.preview_height();
|
||||
while limit > 0 && h.reader.read_line(&mut line)? > 0 {
|
||||
let limit = MANAGER.layout.preview_height();
|
||||
while h.reader.read_line(&mut line)? > 0 {
|
||||
if tick != INCR.load(Ordering::Relaxed) {
|
||||
return Err("Preview cancelled".into());
|
||||
}
|
||||
|
||||
i += 1;
|
||||
if i <= skip {
|
||||
if i > skip + limit {
|
||||
break;
|
||||
} else if i <= skip {
|
||||
line.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
limit -= 1;
|
||||
line = line.replace('\t', &spaces);
|
||||
let regions = h.highlight_lines.highlight_line(&line, syntaxes).map_err(|e| anyhow!(e))?;
|
||||
buf.push_str(&as_24_bit_terminal_escaped(®ions, false));
|
||||
line.clear();
|
||||
}
|
||||
|
||||
if buf.is_empty() {
|
||||
return Err(PagedError::Exceed(i));
|
||||
if skip > 0 && i < skip + limit {
|
||||
return Err(PagedError::Exceed(i.saturating_sub(limit)));
|
||||
}
|
||||
|
||||
buf.push_str("\x1b[0m");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue