add actual path separator value to config
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Jonathan Goren · committed by Jonathan Goren · parent 38b84d0 · Browse files · 3 files·+8 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+8 added−8 removed
- other:+8 added−8 removed
Provenance
- Commit
47e30d3- Tree
0c2d4cf- Author
Jonathan Goren <jonagn@gmail.com>- Committer
Jonathan Goren <jonagn@gmail.com>- Parent
38b84d0
3 files changed+8 added−8 removed
modified:src/config.rs+3 added
109 unmodified lines110 111 /// The separator used to print file paths.112 pub path_separator: Option<String>,113 114+ /// The actual separator, either the system default separator or `path_separator`115+ pub actual_path_separator: String,116+117 /// The maximum number of search results118 pub max_results: Option<usize>,119 120 /// Whether or not to strip the './' prefix for search results2 unmodified linesmodified:src/main.rs+4 added
220 unmodified lines221 222 let path_separator = matches223 .value_of("path-separator")224 .map_or_else(filesystem::default_path_separator, |s| Some(s.to_owned()));225+ let actual_path_separator = path_separator226+ .clone()227+ .unwrap_or_else(|| std::path::MAIN_SEPARATOR.to_string());228 check_path_separator_length(path_separator.as_deref())?;229 230 let size_limits = extract_size_limits(&matches)?;231 let time_constraints = extract_time_constraints(&matches)?;138 unmodified lines370 #[cfg(unix)]371 owner_constraint,372 show_filesystem_errors: matches.is_present("show-errors"),373 path_separator,374+ actual_path_separator,375 max_results: matches376 .value_of("max-results")377 .map(|n| n.parse::<usize>())378 .transpose()191 unmodified linesmodified:src/output.rs+1 added-8 removed
1 unmodified line2 use std::io::{self, Write};3 use std::path::Path;4 5 use lscolors::{Indicator, LsColors, Style};6-use once_cell::sync::Lazy;6 7 use crate::config::Config;8 use crate::dir_entry::DirEntry;9 use crate::error::print_error;10 use crate::exit_codes::ExitCode;11 use crate::filesystem::strip_current_dir;12 14-static MAIN_SEPARATOR_STR: Lazy<String> = Lazy::new(|| std::path::MAIN_SEPARATOR.to_string());15-13 fn replace_path_separator(path: &str, new_path_separator: &str) -> String {14 path.replace(std::path::MAIN_SEPARATOR, new_path_separator)15 }16 35 unmodified lines52 config: &Config,53 style: Option<&Style>,54 ) -> io::Result<()> {55 if entry.file_type().map_or(false, |ft| ft.is_dir()) {59- let separator = config60- .path_separator61- .as_ref()62- .unwrap_or(&MAIN_SEPARATOR_STR);56 write!(57 stdout,58 "{}",59 style60 .map(Style::to_ansi_term_style)61 .unwrap_or_default()69- .paint(separator)62+ .paint(&config.actual_path_separator)63 )?;64 }65 Ok(())66 }105 unmodified lines