Skip to content

Commit

Permalink
Address PR comments.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
cessen committed Jun 15, 2021
1 parent ecb39da commit d415a66
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d415a66

Please sign in to comment.