Skip to content

Commit 607e670

Browse files
sxyaziLemi0002
authored andcommitted
feat: new base field for the Url userdata (sxyazi#2492)
1 parent e03fa4d commit 607e670

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Yazi (means "duck") is a terminal file manager written in Rust, based on non-blo
2828
- 🧰 Integration with ripgrep, fd, fzf, zoxide
2929
- 💫 Vim-like input/pick/confirm/which/notify component, auto-completion for cd paths
3030
- 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, code, directories, etc.)
31-
- 🔄 Bulk Renaming, Visual Mode, File Chooser, [Git Integration](https://github.com/yazi-rs/plugins/tree/main/git.yazi), [Mount Manager](https://github.com/yazi-rs/plugins/tree/main/mount.yazi)
31+
- 🔄 Bulk Renaming, Archive Extraction, Visual Mode, File Chooser, [Git Integration](https://github.com/yazi-rs/plugins/tree/main/git.yazi), [Mount Manager](https://github.com/yazi-rs/plugins/tree/main/mount.yazi)
3232
- 🎨 Theme System, Mouse Support, Trash Bin, Custom Layouts, CSI u, OSC 52
3333
- ... and more!
3434

scripts/bump.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
cd $SCRIPT_DIR/..
66

77
echo "Bumping version: $1"

yazi-config/preset/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Default Configuration
22

33
> [!IMPORTANT]
4-
> If you're using a stable release of Yazi instead of the latest nightly build, make sure you're checking these files from [the `shipped` tag][shipped], not the latest main branch.
4+
> If you're using a stable release of Yazi instead of the newest nightly build, make sure you're checking these files out from [the `shipped` tag][shipped], not the newest `main` branch.
55
66
This directory contains the default configuration files for Yazi:
77

yazi-core/src/tasks/commands/inspect.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ impl Tasks {
3232

3333
terminal_clear(TTY.writer()).ok();
3434
TTY.writer().write_all(buffered.as_bytes()).ok();
35+
TTY.writer().flush().ok();
3536

3637
defer! { disable_raw_mode().ok(); }
3738
enable_raw_mode().ok();

yazi-dds/src/sendable.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,11 @@ impl Sendable {
168168
}
169169

170170
pub fn list_to_values(lua: &Lua, data: Vec<Data>) -> mlua::Result<MultiValue> {
171-
let mut vec = Vec::with_capacity(data.len());
172-
for v in data {
173-
vec.push(Self::data_to_value(lua, v)?);
174-
}
175-
Ok(MultiValue::from_vec(vec))
171+
data.into_iter().map(|d| Self::data_to_value(lua, d)).collect()
176172
}
177173

178174
pub fn values_to_list(values: MultiValue) -> mlua::Result<Vec<Data>> {
179-
let mut vec = Vec::with_capacity(values.len());
180-
for value in values {
181-
vec.push(Self::value_to_data(value)?);
182-
}
183-
Ok(vec)
175+
values.into_iter().map(Self::value_to_data).collect()
184176
}
185177
}
186178

yazi-plugin/src/url/url.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ impl Url {
88
pub fn register(lua: &Lua) -> mlua::Result<()> {
99
lua.register_userdata_type::<yazi_shared::url::Url>(|reg| {
1010
reg.add_method("frag", |lua, me, ()| lua.create_string(me.frag()));
11+
reg.add_field_method_get("base", |_, me| {
12+
Ok(if me.base().as_os_str().is_empty() { None } else { Some(Self::from(me.base())) })
13+
});
1114
reg.add_field_method_get("is_regular", |_, me| Ok(me.is_regular()));
1215
reg.add_field_method_get("is_search", |_, me| Ok(me.is_search()));
1316
reg.add_field_method_get("is_archive", |_, me| Ok(me.is_archive()));
1417
reg.add_field_method_get("is_absolute", |_, me| Ok(me.is_absolute()));
1518
reg.add_field_method_get("has_root", |_, me| Ok(me.has_root()));
1619

1720
reg.add_method("name", |lua, me, ()| {
18-
me.file_name().map(|s| lua.create_string(s.as_encoded_bytes())).transpose()
21+
Some(me.name())
22+
.filter(|&s| !s.is_empty())
23+
.map(|s| lua.create_string(s.as_encoded_bytes()))
24+
.transpose()
1925
});
2026
reg.add_method("stem", |lua, me, ()| {
2127
me.file_stem().map(|s| lua.create_string(s.as_encoded_bytes())).transpose()

yazi-plugin/src/utils/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ impl Utils {
9191
let args = [Ok(Value::Table(plugin))]
9292
.into_iter()
9393
.chain(args.into_iter().map(|d| Sendable::data_to_value(lua, d)))
94-
.collect::<mlua::Result<_>>()?;
94+
.collect::<mlua::Result<MultiValue>>()?;
9595

96-
let values = Sendable::values_to_list(block.call(MultiValue::from_vec(args))?)?;
96+
let values = Sendable::values_to_list(block.call(args)?)?;
9797
tx.send(values).map_err(|_| "send failed".into_lua_err())
9898
})
9999
};

0 commit comments

Comments
 (0)