From c00334cbf50af0f20c1e6ac530dc215b7c7188e7 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Tue, 31 May 2022 00:29:57 +0800 Subject: [PATCH] Try fix find file windows build --- helix-term/src/ui/picker.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index baed70298ff3b..10f9254add28a 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -33,7 +33,7 @@ use helix_view::{ // based on exa but not sure where to put this /// More readable aliases for the permission bits exposed by libc. -#[allow(trivial_numeric_casts)] +#[cfg(unix)] mod modes { // The `libc::mode_t` type’s actual type varies, but the value returned // from `metadata.permissions().mode()` is always `u32`. @@ -57,6 +57,7 @@ mod modes { } // based on exa but not sure where to put this +#[cfg(unix)] mod fields { use super::modes; use std::fmt; @@ -335,17 +336,21 @@ impl FindFilePicker { let suffix = if path.is_dir() { "/" } else { "" }; let metadata = fs::metadata(&*path).unwrap(); let path = path.strip_prefix(&dir1).unwrap_or(path).to_string_lossy(); - let filetype = fields::filetype(&metadata); - let permissions = fields::permissions(&metadata); - let size = format!("{}", fields::size(&metadata)); - Cow::Owned(format!( - "{:<22} {}{} {:>6}", - path + suffix, // TODO this should check for size and handle truncation - filetype, - permissions, - size, - // TODO add absolute/relative time? may need to handle truncation - )) + if cfg!(unix) { + let filetype = fields::filetype(&metadata); + let permissions = fields::permissions(&metadata); + let size = format!("{}", fields::size(&metadata)); + Cow::Owned(format!( + "{:<22} {}{} {:>6}", + path + suffix, // TODO this should check for size and handle truncation + filetype, + permissions, + size, + // TODO add absolute/relative time? may need to handle truncation + )) + } else { + path + suffix + } }, |_cx, _path, _action| {}, // we use custom callback_fn |_editor, path| Some((path.clone(), None)),