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.
This commit is contained in:
parent
ecb39da3e0
commit
d415a666fe
@ -984,14 +984,12 @@ fn set_indent_style(editor: &mut Editor, args: &[&str], event: PromptEvent) {
|
||||
|
||||
let style = match args.get(0) {
|
||||
Some(arg) if "tabs".starts_with(&arg.to_lowercase()) => Some(Tabs),
|
||||
Some(arg) if arg.len() == 1 => {
|
||||
let ch = arg.chars().next().unwrap();
|
||||
if ('1'..='8').contains(&ch) {
|
||||
Some(Spaces(ch.to_digit(10).unwrap() as u8))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Some(&"0") => Some(Tabs),
|
||||
Some(arg) => arg
|
||||
.parse::<u8>()
|
||||
.ok()
|
||||
.filter(|n| (1..=8).contains(n))
|
||||
.map(Spaces),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
@ -1166,7 +1164,7 @@ fn force_quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
|
||||
completer: None,
|
||||
},
|
||||
Command {
|
||||
name: "indent_style",
|
||||
name: "indent-style",
|
||||
alias: None,
|
||||
doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)",
|
||||
fun: set_indent_style,
|
||||
|
Loading…
Reference in New Issue
Block a user