Skip to content

Commit 76196aa

Browse files
authored
refactor!: return Path instead of Url from File.link_to (#3385)
1 parent ade1025 commit 76196aa

File tree

19 files changed

+50
-65
lines changed

19 files changed

+50
-65
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
4545
- Rename `name` to `url` for open, fetchers, spotters, preloaders, previewers, filetype, and `globs` icon rules to support virtual file system ([#3034])
4646
- Rename `mime` fetcher to `mime.local`, and introduce `mime.dir` fetcher to support folder MIME types ([#3222])
4747
- Remove `$0` parameter in opener rules to make the `open` command work under empty directories ([#3226])
48-
- Return `Path` instead of `Url` from `Url:strip_prefix()` to enforce type safety ([#3361])
48+
- Return `Path` instead of `Url` from `Url:strip_prefix()` and `File.link_to` to enforce type safety ([#3361], [#3385])
4949
- Use `body` instead of the term `content` in confirmations ([#2921])
5050
- Use `u16` instead of `u32` as the type of `max_width` and `max_height` options to avoid memory exhaustion ([#3313])
5151
- Implement `__pairs` metamethod instead of `__index` for the callback argument of the `@yank` DDS event ([#2997])
@@ -1543,3 +1543,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
15431543
[#3360]: https://github.com/sxyazi/yazi/pull/3360
15441544
[#3364]: https://github.com/sxyazi/yazi/pull/3364
15451545
[#3369]: https://github.com/sxyazi/yazi/pull/3369
1546+
[#3385]: https://github.com/sxyazi/yazi/pull/3385

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.

yazi-actor/src/mgr/enter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use yazi_macro::{act, succ};
33
use yazi_parser::{VoidOpt, mgr::CdSource};
4-
use yazi_shared::data::Data;
4+
use yazi_shared::{data::Data, url::UrlLike};
55

66
use crate::{Actor, Ctx};
77

yazi-actor/src/mgr/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{Result, bail};
22
use yazi_macro::{act, render, render_and, succ};
33
use yazi_parser::{VoidOpt, mgr::EscapeOpt};
44
use yazi_proxy::AppProxy;
5-
use yazi_shared::data::Data;
5+
use yazi_shared::{data::Data, url::UrlLike};
66

77
use crate::{Actor, Ctx};
88

yazi-actor/src/mgr/follow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use yazi_fs::path::clean_url;
33
use yazi_macro::{act, succ};
4-
use yazi_parser::VoidOpt;
4+
use yazi_parser::{VoidOpt, mgr::CdSource};
55
use yazi_shared::{data::Data, url::UrlLike};
66

77
use crate::{Actor, Ctx};
@@ -18,6 +18,6 @@ impl Actor for Follow {
1818
let Some(link_to) = &file.link_to else { succ!() };
1919
let Some(parent) = file.url.parent() else { succ!() };
2020
let Ok(joined) = parent.try_join(link_to) else { succ!() };
21-
act!(mgr:reveal, cx, clean_url(joined))
21+
act!(mgr:reveal, cx, (clean_url(joined), CdSource::Follow))
2222
}
2323
}

yazi-actor/src/mgr/refresh.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ impl Refresh {
5757
}
5858
}
5959

60-
let futs: Vec<_> =
61-
folders.iter().filter(|&f| f.url.is_internal()).map(|&f| go(f.url.clone(), f.cha)).collect();
60+
let futs: Vec<_> = folders
61+
.iter()
62+
.filter(|&f| f.url.is_absolute() && f.url.is_internal())
63+
.map(|&f| go(f.url.clone(), f.cha))
64+
.collect();
6265

6366
if !futs.is_empty() {
6467
tokio::spawn(futures::future::join_all(futs));

yazi-actor/src/mgr/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use yazi_macro::{act, succ};
99
use yazi_parser::{VoidOpt, mgr::{CdSource, SearchOpt, SearchOptVia}};
1010
use yazi_plugin::external;
1111
use yazi_proxy::{InputProxy, MgrProxy};
12-
use yazi_shared::data::Data;
12+
use yazi_shared::{data::Data, url::UrlLike};
1313

1414
use crate::{Actor, Ctx};
1515

yazi-actor/src/mgr/stash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::Result;
22
use yazi_dds::spark::SparkKind;
33
use yazi_macro::succ;
44
use yazi_parser::mgr::StashOpt;
5-
use yazi_shared::{Source, data::Data, url::AsUrl};
5+
use yazi_shared::{Source, data::Data, url::{AsUrl, UrlLike}};
66

77
use crate::{Actor, Ctx};
88

@@ -14,7 +14,7 @@ impl Actor for Stash {
1414
const NAME: &str = "stash";
1515

1616
fn act(cx: &mut Ctx, opt: Self::Options) -> Result<Data> {
17-
if opt.target.is_regular() {
17+
if opt.target.is_internal() {
1818
cx.tab_mut().backstack.push(opt.target.as_url());
1919
}
2020

yazi-actor/src/mgr/tab_create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use yazi_core::tab::Tab;
33
use yazi_macro::{act, render, succ};
44
use yazi_parser::mgr::{CdSource, TabCreateOpt};
55
use yazi_proxy::AppProxy;
6-
use yazi_shared::data::Data;
6+
use yazi_shared::{data::Data, url::UrlLike};
77

88
use crate::{Actor, Ctx};
99

yazi-binding/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ macro_rules! impl_file_fields {
151151
($fields:ident) => {
152152
$crate::cached_field!($fields, cha, |_, me| Ok($crate::Cha(me.cha)));
153153
$crate::cached_field!($fields, url, |_, me| Ok($crate::Url::new(me.url_owned())));
154-
$crate::cached_field!($fields, link_to, |_, me| Ok(me.link_to_url().map($crate::Url::new)));
154+
$crate::cached_field!($fields, link_to, |_, me| Ok(me.link_to.as_ref().map($crate::Path::new)));
155155

156156
$crate::cached_field!($fields, name, |lua, me| {
157157
me.name().map(|s| lua.create_string(s.encoded_bytes())).transpose()

0 commit comments

Comments
 (0)