Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-stdx/src/path.rs')
| -rw-r--r-- | helix-stdx/src/path.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/helix-stdx/src/path.rs b/helix-stdx/src/path.rs index 740f7bcb..72b233cc 100644 --- a/helix-stdx/src/path.rs +++ b/helix-stdx/src/path.rs @@ -1,5 +1,3 @@ -//! Functions for working with [Path]. - pub use etcetera::home_dir; use once_cell::sync::Lazy; use regex_cursor::{engines::meta::Regex, Input}; @@ -35,9 +33,7 @@ where } /// Expands tilde `~` into users home directory if available, otherwise returns the path -/// unchanged. -/// -/// The tilde will only be expanded when present as the first component of the path +/// unchanged. The tilde will only be expanded when present as the first component of the path /// and only slash follows it. pub fn expand_tilde<'a, P>(path: P) -> Cow<'a, Path> where @@ -58,11 +54,11 @@ where } /// Normalize a path without resolving symlinks. -// Strategy: start from the first component and move up. Canonicalize previous path, +// Strategy: start from the first component and move up. Cannonicalize previous path, // join component, canonicalize new path, strip prefix and join to the final result. pub fn normalize(path: impl AsRef<Path>) -> PathBuf { let mut components = path.as_ref().components().peekable(); - let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().copied() { + let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() { components.next(); PathBuf::from(c.as_os_str()) } else { @@ -142,7 +138,6 @@ pub fn canonicalize(path: impl AsRef<Path>) -> PathBuf { normalize(path) } -/// Convert path into a relative path pub fn get_relative_path<'a, P>(path: P) -> Cow<'a, Path> where P: Into<Cow<'a, Path>>, @@ -214,7 +209,7 @@ fn path_component_regex(windows: bool) -> String { // TODO: support backslash path escape on windows (when using git bash for example) let space_escape = if windows { r"[\^`]\s" } else { r"[\\]\s" }; // partially baesd on what's allowed in an url but with some care to avoid - // false positives (like any kind of brackets or quotes) + // false positivies (like any kind of brackets or quotes) r"[\w@.\-+#$%?!,;~&]|".to_owned() + space_escape } |