aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorNathan Vegdahl2021-06-14 20:22:25 +0000
committerNathan Vegdahl2021-06-15 01:32:23 +0000
commitd415a666feab2c5c7a5dc190a9bded7382c2e0e8 (patch)
tree292b691fc8cde8ca447cf3c40fd92a3c981ad55b /helix-term
parentecb39da3e06eeeabe844cafb76feb233052ce4cb (diff)
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.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs16
1 files changed, 7 insertions, 9 deletions
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::<u8>()
+ .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,