Skip to content

Commit 8b3ce18

Browse files
authored
feat!: new @sync peek annotation for sync previewers (#2487)
1 parent 324a439 commit 8b3ce18

File tree

18 files changed

+104
-105
lines changed

18 files changed

+104
-105
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ clap = { version = "4.5.32", features = [ "derive" ] }
2222
core-foundation-sys = "0.8.7"
2323
crossterm = { version = "0.28.1", features = [ "event-stream" ] }
2424
dirs = "6.0.0"
25-
foldhash = "0.1.4"
25+
foldhash = "0.1.5"
2626
futures = "0.3.31"
2727
globset = "0.4.16"
2828
indexmap = { version = "2.8.0", features = [ "serde" ] }

yazi-config/preset/keymap-default.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ keymap = [
3030
{ on = "<PageDown>", run = "arrow 100%", desc = "Move cursor down one page" },
3131

3232
{ on = [ "g", "g" ], run = "arrow top", desc = "Move cursor to the top" },
33-
{ on = "G", run = "arrow bot", desc = "Move cursor to the bottom" },
33+
{ on = "G", run = "arrow bot", desc = "Move cursor to the bottom" },
3434

3535
# Navigation
36-
{ on = "h", run = "leave", desc = "Go back to the parent directory" },
36+
{ on = "h", run = "leave", desc = "Back to the parent directory" },
3737
{ on = "l", run = "enter", desc = "Enter the child directory" },
3838

39-
{ on = "<Left>", run = "leave", desc = "Go back to the parent directory" },
39+
{ on = "<Left>", run = "leave", desc = "Back to the parent directory" },
4040
{ on = "<Right>", run = "enter", desc = "Enter the child directory" },
4141

4242
{ on = "H", run = "back", desc = "Back to previous directory" },

yazi-config/preset/yazi-default.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ preloaders = [
118118
{ mime = "application/ms-opentype", run = "font" },
119119
]
120120
previewers = [
121-
{ name = "*/", run = "folder", sync = true },
121+
{ name = "*/", run = "folder" },
122122
# Code
123123
{ mime = "text/*", run = "code" },
124124
{ mime = "application/{mbox,javascript,wine-extension-ini}", run = "code" },

yazi-config/src/plugin/previewer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ pub struct Previewer {
1010
pub name: Option<Pattern>,
1111
pub mime: Option<Pattern>,
1212
pub run: Cmd,
13-
#[serde(default)]
14-
pub sync: bool,
1513
}
1614

1715
impl Previewer {

yazi-core/src/tab/preview.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ impl Preview {
3232
};
3333

3434
self.abort();
35-
if previewer.sync {
36-
isolate::peek_sync(&previewer.run, file, mime, self.skip);
37-
} else {
38-
self.previewer_ct = Some(isolate::peek(&previewer.run, file, mime, self.skip));
39-
}
35+
self.previewer_ct = isolate::peek(&previewer.run, file, mime, self.skip);
4036
}
4137

4238
pub fn go_folder(&mut self, file: File, dir: Option<Cha>, force: bool) {

yazi-fm/src/app/commands/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl App {
2929
}
3030

3131
tokio::spawn(async move {
32-
match LOADER.ensure(&opt.id).await {
32+
match LOADER.ensure(&opt.id, |_| ()).await {
3333
Ok(()) => AppProxy::plugin_do(opt),
3434
Err(e) => AppProxy::notify_error("Plugin load failed", e),
3535
}

yazi-fm/src/term.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ impl Term {
3535
execute!(
3636
TTY.writer(),
3737
screen::SetScreen(true),
38-
Print(Mux::csi("\x1bP$q q\x1b\\")), // Request cursor shape (DECRQSS query for DECSCUSR)
39-
Print(Mux::csi("\x1b[?12$p")), // Request cursor blink status (DECSET)
40-
Print("\x1b[?u"), // Request keyboard enhancement flags (CSI u)
41-
Print(Mux::csi("\x1b[0c")), // Request device attributes
38+
Print("\x1bP$q q\x1b\\"), // Request cursor shape (DECRQSS query for DECSCUSR)
39+
Print(Mux::csi("\x1b[?12$p")), // Request cursor blink status (DECSET)
40+
Print("\x1b[?u"), // Request keyboard enhancement flags (CSI u)
41+
Print(Mux::csi("\x1b[0c")), // Request device attributes
4242
screen::SetScreen(false),
4343
EnableBracketedPaste,
4444
mouse::SetMouse(true),

yazi-plugin/preset/plugins/folder.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
--- @sync peek
2+
13
local M = {}
24

35
function M:peek(job)

yazi-plugin/src/config/runtime.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,11 @@ impl<'a> Runtime<'a> {
2929
}
3030

3131
fn args(lua: &Lua) -> mlua::Result<Value> {
32-
Composer::make(lua, 5, |lua, key| {
33-
match key {
34-
b"entries" => {
35-
lua.create_sequence_from(ARGS.entries.iter().map(Url::from))?.into_lua(lua)?
36-
}
37-
b"cwd_file" => ARGS.cwd_file.as_ref().map(Url::from).into_lua(lua)?,
38-
b"chooser_file" => ARGS.chooser_file.as_ref().map(Url::from).into_lua(lua)?,
39-
_ => return Ok(Value::Nil),
40-
}
41-
.into_lua(lua)
32+
Composer::make(lua, 5, |lua, key| match key {
33+
b"entries" => lua.create_sequence_from(ARGS.entries.iter().map(Url::from))?.into_lua(lua),
34+
b"cwd_file" => ARGS.cwd_file.as_ref().map(Url::from).into_lua(lua),
35+
b"chooser_file" => ARGS.chooser_file.as_ref().map(Url::from).into_lua(lua),
36+
_ => Ok(Value::Nil),
4237
})
4338
}
4439

0 commit comments

Comments
 (0)