Address PR comments.

* Clean up "indent-style" command argument parsing.
* Adjust command's name to match the style of other commands.
* Add a "0" alias to the command, for tabs indent style.
pull/269/head
Nathan Vegdahl 3 years ago
parent ecb39da3e0
commit d415a666fe

@ -984,14 +984,12 @@ mod cmd {
let style = match args.get(0) { let style = match args.get(0) {
Some(arg) if "tabs".starts_with(&arg.to_lowercase()) => Some(Tabs), Some(arg) if "tabs".starts_with(&arg.to_lowercase()) => Some(Tabs),
Some(arg) if arg.len() == 1 => { Some(&"0") => Some(Tabs),
let ch = arg.chars().next().unwrap(); Some(arg) => arg
if ('1'..='8').contains(&ch) { .parse::<u8>()
Some(Spaces(ch.to_digit(10).unwrap() as u8)) .ok()
} else { .filter(|n| (1..=8).contains(n))
None .map(Spaces),
}
}
_ => None, _ => None,
}; };
@ -1166,7 +1164,7 @@ mod cmd {
completer: None, completer: None,
}, },
Command { Command {
name: "indent_style", name: "indent-style",
alias: None, alias: None,
doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)", doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)",
fun: set_indent_style, fun: set_indent_style,

Loading…
Cancel
Save