From d415a666feab2c5c7a5dc190a9bded7382c2e0e8 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Mon, 14 Jun 2021 13:22:25 -0700 Subject: 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. --- helix-term/src/commands.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 94003c2e..fb254432 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -984,14 +984,12 @@ mod cmd { 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::() + .ok() + .filter(|n| (1..=8).contains(n)) + .map(Spaces), _ => None, }; @@ -1166,7 +1164,7 @@ mod cmd { 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, -- cgit v1.2.3-70-g09d2