From 728852c750d2d919a30b1cd11da5a720a00a057a Mon Sep 17 00:00:00 2001 From: Jason Gedge Date: Thu, 27 Aug 2020 10:14:04 -0400 Subject: [PATCH] Remove unnecessary reference to ichwh in command completer (#2435) --- crates/nu-cli/src/completion/command.rs | 30 +++++++++---------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/crates/nu-cli/src/completion/command.rs b/crates/nu-cli/src/completion/command.rs index a4e9d17305..c9ca2e0458 100644 --- a/crates/nu-cli/src/completion/command.rs +++ b/crates/nu-cli/src/completion/command.rs @@ -1,8 +1,6 @@ use std::fs::{read_dir, DirEntry}; use std::iter::FromIterator; -#[cfg(all(windows, feature = "ichwh"))] -use ichwh::{IchwhError, IchwhResult}; use indexmap::set::IndexSet; use crate::completion::{Context, Suggestion}; @@ -31,23 +29,15 @@ impl Completer { } } -// These is_executable/pathext implementations are copied from ichwh and modified -// to not be async - -#[cfg(all(windows, feature = "ichwh"))] -fn pathext() -> IchwhResult> { - Ok(std::env::var_os("PATHEXT") - .ok_or(IchwhError::PathextNotDefined)? - .to_string_lossy() - .split(';') - // Cut off the leading '.' character - .map(|ext| ext[1..].to_string()) - .collect::>()) -} - -#[cfg(all(windows, not(feature = "ichwh")))] -fn pathext() -> Result, ()> { - Err(()) +#[cfg(windows)] +fn pathext() -> Option> { + std::env::var_os("PATHEXT").map(|v| { + v.to_string_lossy() + .split(';') + // Cut off the leading '.' character + .map(|ext| ext[1..].to_string()) + .collect::>() + }) } #[cfg(windows)] @@ -61,7 +51,7 @@ fn is_executable(file: &DirEntry) -> bool { } if let Some(extension) = file.path().extension() { - if let Ok(exts) = pathext() { + if let Some(exts) = pathext() { exts.iter() .any(|ext| extension.to_string_lossy().eq_ignore_ascii_case(ext)) } else {