diff options
author | Nathan Vegdahl | 2021-06-15 02:43:24 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-06-15 03:33:42 +0000 |
commit | 7c2fb92c9170ff108bef244e7aed82e29156ae5c (patch) | |
tree | 946b214ae62d1d02e2df3f3e2f2c7cdafdb3b8b1 /helix-term/src | |
parent | d415a666feab2c5c7a5dc190a9bded7382c2e0e8 (diff) |
Report indent style when calling indent-style with no arguments.
Also print an error message when the argument is malformed.
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index fb254432..0f2a29c6 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -982,6 +982,19 @@ mod cmd { fn set_indent_style(editor: &mut Editor, args: &[&str], event: PromptEvent) { use IndentStyle::*; + // If no argument, report current indent style. + if args.is_empty() { + let style = editor.current().1.indent_style; + editor.set_status(match style { + Tabs => "tabs".into(), + Spaces(1) => "1 space".into(), + Spaces(n) if (2..=8).contains(&n) => format!("{} spaces", n), + _ => "error".into(), // Shouldn't happen. + }); + return; + } + + // Attempt to parse argument as an indent style. let style = match args.get(0) { Some(arg) if "tabs".starts_with(&arg.to_lowercase()) => Some(Tabs), Some(&"0") => Some(Tabs), @@ -996,6 +1009,9 @@ mod cmd { if let Some(s) = style { let (_, doc) = editor.current(); doc.indent_style = s; + } else { + // Invalid argument. + editor.set_error(format!("invalid indent style '{}'", args[0],)); } } |