mirror of
https://github.com/nushell/nushell
synced 2024-12-28 14:03:09 +00:00
Remove unnecessary reference to ichwh in command completer (#2435)
This commit is contained in:
parent
26cec83b63
commit
728852c750
1 changed files with 10 additions and 20 deletions
|
@ -1,8 +1,6 @@
|
||||||
use std::fs::{read_dir, DirEntry};
|
use std::fs::{read_dir, DirEntry};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
|
||||||
#[cfg(all(windows, feature = "ichwh"))]
|
|
||||||
use ichwh::{IchwhError, IchwhResult};
|
|
||||||
use indexmap::set::IndexSet;
|
use indexmap::set::IndexSet;
|
||||||
|
|
||||||
use crate::completion::{Context, Suggestion};
|
use crate::completion::{Context, Suggestion};
|
||||||
|
@ -31,23 +29,15 @@ impl Completer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// These is_executable/pathext implementations are copied from ichwh and modified
|
#[cfg(windows)]
|
||||||
// to not be async
|
fn pathext() -> Option<Vec<String>> {
|
||||||
|
std::env::var_os("PATHEXT").map(|v| {
|
||||||
#[cfg(all(windows, feature = "ichwh"))]
|
v.to_string_lossy()
|
||||||
fn pathext() -> IchwhResult<Vec<String>> {
|
|
||||||
Ok(std::env::var_os("PATHEXT")
|
|
||||||
.ok_or(IchwhError::PathextNotDefined)?
|
|
||||||
.to_string_lossy()
|
|
||||||
.split(';')
|
.split(';')
|
||||||
// Cut off the leading '.' character
|
// Cut off the leading '.' character
|
||||||
.map(|ext| ext[1..].to_string())
|
.map(|ext| ext[1..].to_string())
|
||||||
.collect::<Vec<_>>())
|
.collect::<Vec<_>>()
|
||||||
}
|
})
|
||||||
|
|
||||||
#[cfg(all(windows, not(feature = "ichwh")))]
|
|
||||||
fn pathext() -> Result<Vec<String>, ()> {
|
|
||||||
Err(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
@ -61,7 +51,7 @@ fn is_executable(file: &DirEntry) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(extension) = file.path().extension() {
|
if let Some(extension) = file.path().extension() {
|
||||||
if let Ok(exts) = pathext() {
|
if let Some(exts) = pathext() {
|
||||||
exts.iter()
|
exts.iter()
|
||||||
.any(|ext| extension.to_string_lossy().eq_ignore_ascii_case(ext))
|
.any(|ext| extension.to_string_lossy().eq_ignore_ascii_case(ext))
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue