diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 3e5d261b..517f98a4 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -26,7 +26,7 @@ body: attributes: label: Yazi version description: Please do a `yazi -V` and paste the output here. - placeholder: "ex: yazi 0.1.5" + placeholder: "ex: yazi 0.1.5 (3867c29 2023-11-25)" validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index be2d510c..14e0b0a0 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -14,7 +14,7 @@ body: label: Will you be willing to contribute this feature? description: The feature has a much higher chance of completion if you are willing to get involved! options: - - label: Yes, I will try to implement it + - label: Yes, I'll give it a shot - type: textarea id: solution attributes: diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 053d787d..c76f7ba0 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -2,27 +2,26 @@ name: Lock Threads on: schedule: - - cron: '5 3 * * *' + - cron: "5 3 * * *" workflow_dispatch: -permissions: - issues: write - pull-requests: write - concurrency: group: lock jobs: - action: + lock: runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write steps: - uses: dessant/lock-threads@v4 with: - issue-inactive-days: '30' + issue-inactive-days: "30" issue-comment: > I'm going to lock this issue because it has been closed for _30 days_. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. - process-only: 'issues' + process-only: "issues" diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml index 46d38d51..37039061 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/no-response.yml @@ -4,13 +4,16 @@ on: issue_comment: types: [created] schedule: - - cron: '10 * * * *' + - cron: "10 * * * *" jobs: noResponse: runs-on: ubuntu-latest + permissions: + issues: write steps: - uses: lee-dohm/no-response@v0.5.0 with: token: ${{ github.token }} + daysUntilClose: 7 responseRequiredLabel: waiting on op diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0072fe94..1d983ba2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,9 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install stable toolchain + run: rustup toolchain install stable --profile minimal + - name: Add aarch64 target if: contains(fromJson('["aarch64-unknown-linux-gnu", "aarch64-apple-darwin"]'), matrix.target) run: rustup target add ${{ matrix.target }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09de2723..4aa09fe4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,9 @@ name: Test on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] env: CARGO_TERM_COLOR: always @@ -20,6 +20,9 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install stable toolchain + run: rustup toolchain install stable --profile minimal + - name: Cache dependencies uses: Swatinem/rust-cache@v2 diff --git a/yazi-core/src/external/clipboard.rs b/yazi-core/src/external/clipboard.rs index e6f95e30..0e0f7c1e 100644 --- a/yazi-core/src/external/clipboard.rs +++ b/yazi-core/src/external/clipboard.rs @@ -39,7 +39,7 @@ pub async fn clipboard_get() -> Result { #[cfg(unix)] pub async fn clipboard_set(s: impl AsRef) -> Result<()> { - use std::{os::unix::prelude::OsStrExt, process::Stdio}; + use std::process::Stdio; use anyhow::bail; use tokio::{io::AsyncWriteExt, process::Command}; @@ -64,7 +64,7 @@ pub async fn clipboard_set(s: impl AsRef) -> Result<()> { }; let mut stdin = child.stdin.take().unwrap(); - if stdin.write_all(s.as_ref().as_bytes()).await.is_err() { + if stdin.write_all(s.as_ref().as_encoded_bytes()).await.is_err() { continue; } drop(stdin); diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/manager/commands/rename.rs index ad5c988d..8391e894 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/manager/commands/rename.rs @@ -75,16 +75,13 @@ impl Manager { { let s = old.iter().map(|o| o.as_os_str()).collect::>().join(OsStr::new("\n")); - let mut f = OpenOptions::new().write(true).create_new(true).open(&tmp).await?; - #[cfg(windows)] - { - f.write_all(s.to_string_lossy().as_bytes()).await?; - } - #[cfg(unix)] - { - use std::os::unix::ffi::OsStrExt; - f.write_all(s.as_bytes()).await?; - } + OpenOptions::new() + .write(true) + .create_new(true) + .open(&tmp) + .await? + .write_all(s.as_encoded_bytes()) + .await?; } let _guard = BLOCKER.acquire().await.unwrap(); diff --git a/yazi-core/src/tab/finder.rs b/yazi-core/src/tab/finder.rs index 0e297d27..db6112b0 100644 --- a/yazi-core/src/tab/finder.rs +++ b/yazi-core/src/tab/finder.rs @@ -77,31 +77,12 @@ impl Finder { } #[inline] - fn matches(&self, name: &OsStr) -> bool { - #[cfg(windows)] - { - self.query.is_match(name.to_string_lossy().as_bytes()) - } - #[cfg(unix)] - { - use std::os::unix::ffi::OsStrExt; - self.query.is_match(name.as_bytes()) - } - } + fn matches(&self, name: &OsStr) -> bool { self.query.is_match(name.as_encoded_bytes()) } /// Explode the name into three parts: head, body, tail. #[inline] pub fn highlighted(&self, name: &OsStr) -> Option>> { - #[cfg(windows)] - let found = self.query.find(name.to_string_lossy().as_bytes()).map(|m| m.range()); - - #[cfg(unix)] - let found = { - use std::os::unix::ffi::OsStrExt; - self.query.find(name.as_bytes()).map(|m| m.range()) - }; - - found.map(|r| vec![r]) + self.query.find(name.as_encoded_bytes()).map(|m| vec![m.range()]) } } diff --git a/yazi-fm/src/app.rs b/yazi-fm/src/app.rs index f1d25f9a..b34584e5 100644 --- a/yazi-fm/src/app.rs +++ b/yazi-fm/src/app.rs @@ -46,16 +46,7 @@ impl App { fn dispatch_quit(&mut self, no_cwd_file: bool) { if let Some(p) = BOOT.cwd_file.as_ref().filter(|_| !no_cwd_file) { let cwd = self.cx.manager.cwd().as_os_str(); - - #[cfg(windows)] - { - std::fs::write(p, cwd.to_string_lossy().as_bytes()).ok(); - } - #[cfg(unix)] - { - use std::os::unix::ffi::OsStrExt; - std::fs::write(p, cwd.as_bytes()).ok(); - } + std::fs::write(p, cwd.as_encoded_bytes()).ok(); } Term::goodbye(|| false).unwrap(); } @@ -203,15 +194,7 @@ impl App { s }); - #[cfg(windows)] - { - std::fs::write(p, paths.to_string_lossy().as_bytes()).ok(); - } - #[cfg(unix)] - { - use std::os::unix::ffi::OsStrExt; - std::fs::write(p, paths.as_bytes()).ok(); - } + std::fs::write(p, paths.as_encoded_bytes()).ok(); return emit!(Quit(false)); } diff --git a/yazi-shared/src/path.rs b/yazi-shared/src/path.rs index 1d197c8f..eadf83cf 100644 --- a/yazi-shared/src/path.rs +++ b/yazi-shared/src/path.rs @@ -48,23 +48,8 @@ pub fn expand_path(p: impl AsRef) -> PathBuf { _expand_path(p.as_ref()) } #[inline] pub fn ends_with_slash(p: &Path) -> bool { - // TODO: uncomment this when Rust 1.74 is released - // let b = p.as_os_str().as_encoded_bytes(); - // if let [.., last] = b { *last == MAIN_SEPARATOR as u8 } else { false } - - #[cfg(unix)] - { - use std::os::unix::ffi::OsStrExt; - let b = p.as_os_str().as_bytes(); - if let [.., last] = b { *last == MAIN_SEPARATOR as u8 } else { false } - } - - #[cfg(windows)] - { - let s = p.to_string_lossy(); - let b = s.as_bytes(); - if let [.., last] = b { *last == MAIN_SEPARATOR as u8 } else { false } - } + let b = p.as_os_str().as_encoded_bytes(); + if let [.., last] = b { *last == MAIN_SEPARATOR as u8 } else { false } } pub async fn unique_path(mut p: Url) -> Url { diff --git a/yazi-shared/src/url.rs b/yazi-shared/src/url.rs index 4724c4c7..ae444097 100644 --- a/yazi-shared/src/url.rs +++ b/yazi-shared/src/url.rs @@ -107,16 +107,8 @@ impl ToString for Url { UrlScheme::Archive => "archive://", }; - #[cfg(unix)] - let path = { - use std::os::unix::ffi::OsStrExt; - percent_encode(self.path.as_os_str().as_bytes(), ENCODE_SET) - }; - #[cfg(windows)] - let path = percent_encode(self.path.to_string_lossy().as_bytes(), ENCODE_SET).to_string(); - + let path = percent_encode(self.path.as_os_str().as_encoded_bytes(), ENCODE_SET); let frag = self.frag.as_ref().map(|s| format!("#{s}")).unwrap_or_default(); - format!("{scheme}{path}{frag}") } }