Skip to content

Commit

Permalink
swap shoud_quote variable with literal
Browse files Browse the repository at this point in the history
  • Loading branch information
PanGan21 committed Sep 14, 2023
1 parent 7ef7c3d commit 78ddaf2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ hyperlink: never
symlink-arrow: ⇒
# == Literal ==
# Whether to display the quotes on filenames.
# Whether to print entry names without quoting
# Possible values: false, true
literal: false
"#;
Expand Down Expand Up @@ -396,7 +396,7 @@ mod tests {
symlink_arrow: Some("⇒".into()),
hyperlink: Some(HyperlinkOption::Never),
header: None,
literal: None,
literal: Some(false),
},
c
);
Expand Down
2 changes: 1 addition & 1 deletion src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Core {
// or require a raw output (like the `wc` command).
inner_flags.layout = Layout::OneLine;

flags.should_quote = Literal(false);
flags.literal = Literal(true);
};

let sorters = sort::assemble_sorters(&flags);
Expand Down
2 changes: 1 addition & 1 deletion src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ fn get_output(
icons,
display_option,
flags.hyperlink,
!flags.should_quote.0,
flags.literal.0,
),
meta.indicator.render(flags),
]);
Expand Down
4 changes: 2 additions & 2 deletions src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub struct Flags {
pub symlink_arrow: SymlinkArrow,
pub hyperlink: HyperlinkOption,
pub header: Header,
pub should_quote: Literal,
pub literal: Literal,
}

impl Flags {
Expand Down Expand Up @@ -104,7 +104,7 @@ impl Flags {
symlink_arrow: SymlinkArrow::configure_from(cli, config),
hyperlink: HyperlinkOption::configure_from(cli, config),
header: Header::configure_from(cli, config),
should_quote: Literal::configure_from(cli, config),
literal: Literal::configure_from(cli, config),
})
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/meta/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ impl Name {
.collect()
}

fn escape(&self, string: &str, should_quote: bool) -> String {
fn escape(&self, string: &str, literal: bool) -> String {
let mut name = string.to_string();
if should_quote {
if !literal {
if name.contains('\\') || name.contains('"') {
name = name.replace('\'', "\'\\\'\'");
name = format!("\'{}\'", &name);
Expand Down Expand Up @@ -153,21 +153,21 @@ impl Name {
format!(
"{}{}",
icons.get(self),
self.hyperlink(self.escape(self.file_name(), quote), hyperlink)
self.hyperlink(self.escape(self.file_name(), !quote), hyperlink)
)
}
DisplayOption::Relative { base_path } => format!(
"{}{}",
icons.get(self),
self.hyperlink(
self.escape(&self.relative_path(base_path).to_string_lossy(), quote),
self.escape(&self.relative_path(base_path).to_string_lossy(), !quote),
hyperlink
)
),
DisplayOption::None => format!(
"{}{}",
icons.get(self),
self.hyperlink(self.escape(&self.path.to_string_lossy(), quote), hyperlink)
self.hyperlink(self.escape(&self.path.to_string_lossy(), !quote), hyperlink)
),
};

Expand Down

0 comments on commit 78ddaf2

Please sign in to comment.