on master help sign in
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.

commitd415a666feab2c5c7a5dc190a9bded7382c2e0e8 authorNathan Vegdahl <cessen@cessen.com> dateMon 14 Jun 2021, 13:22 (5 years ago) parentecb39da
1 file changed+7−9
helix-term/src/commands.rs+7−9
helix-term/src/commands.rs+7−9
@@ -984,14 +984,12 @@ mod cmd {
984984
985985 let style = match args.get(0) {
986986 Some(arg) if "tabs".starts_with(&arg.to_lowercase()) => Some(Tabs),
987− Some(arg) if arg.len() == 1 => {
988− let ch = arg.chars().next().unwrap();
989− if ('1'..='8').contains(&ch) {
990− Some(Spaces(ch.to_digit(10).unwrap() as u8))
991− } else {
992− None
993− }
994− }
987+ Some(&"0") => Some(Tabs),
988+ Some(arg) => arg
989+ .parse::<u8>()
990+ .ok()
991+ .filter(|n| (1..=8).contains(n))
992+ .map(Spaces),
995993 _ => None,
996994 };
997995
@@ -1166,7 +1164,7 @@ mod cmd {
11661164 completer: None,
11671165 },
11681166 Command {
1169− name: "indent_style",
1167+ name: "indent-style",
11701168 alias: None,
11711169 doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)",
11721170 fun: set_indent_style,