Skip to content

Commit c00334c

Browse files
committed
Try fix find file windows build
1 parent a4a8b34 commit c00334c

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

helix-term/src/ui/picker.rs

+17-12
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use helix_view::{
3333

3434
// based on exa but not sure where to put this
3535
/// More readable aliases for the permission bits exposed by libc.
36-
#[allow(trivial_numeric_casts)]
36+
#[cfg(unix)]
3737
mod modes {
3838
// The `libc::mode_t` type’s actual type varies, but the value returned
3939
// from `metadata.permissions().mode()` is always `u32`.
@@ -57,6 +57,7 @@ mod modes {
5757
}
5858

5959
// based on exa but not sure where to put this
60+
#[cfg(unix)]
6061
mod fields {
6162
use super::modes;
6263
use std::fmt;
@@ -335,17 +336,21 @@ impl FindFilePicker {
335336
let suffix = if path.is_dir() { "/" } else { "" };
336337
let metadata = fs::metadata(&*path).unwrap();
337338
let path = path.strip_prefix(&dir1).unwrap_or(path).to_string_lossy();
338-
let filetype = fields::filetype(&metadata);
339-
let permissions = fields::permissions(&metadata);
340-
let size = format!("{}", fields::size(&metadata));
341-
Cow::Owned(format!(
342-
"{:<22} {}{} {:>6}",
343-
path + suffix, // TODO this should check for size and handle truncation
344-
filetype,
345-
permissions,
346-
size,
347-
// TODO add absolute/relative time? may need to handle truncation
348-
))
339+
if cfg!(unix) {
340+
let filetype = fields::filetype(&metadata);
341+
let permissions = fields::permissions(&metadata);
342+
let size = format!("{}", fields::size(&metadata));
343+
Cow::Owned(format!(
344+
"{:<22} {}{} {:>6}",
345+
path + suffix, // TODO this should check for size and handle truncation
346+
filetype,
347+
permissions,
348+
size,
349+
// TODO add absolute/relative time? may need to handle truncation
350+
))
351+
} else {
352+
path + suffix
353+
}
349354
},
350355
|_cx, _path, _action| {}, // we use custom callback_fn
351356
|_editor, path| Some((path.clone(), None)),

0 commit comments

Comments
 (0)