diff options
author | James O. D. Hunt | 2022-10-26 02:59:50 +0000 |
---|---|---|
committer | GitHub | 2022-10-26 02:59:50 +0000 |
commit | ac0fe29867012ba0840ee7c8893b41d976d5ab38 (patch) | |
tree | 0034ee4dae556a32ea2066b712314561a9d7369d /helix-term | |
parent | ba9e50e93b43f102de352ead57c28d86c34a7c73 (diff) |
commands: Make no arg ':theme' show name (#3740)
Most commands that accept an argument show their current value if no
argument is specified. The `:theme` command previously displayed an
error message in the status bar if not provided with an argument:
```
Theme name not provided
```
It now shows the current theme name in the status bar if no argument is
specified.
Signed-off-by: James O. D. Hunt <jamesodhunt@gmail.com>
Signed-off-by: James O. D. Hunt <jamesodhunt@gmail.com>
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands/typed.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 9b79c3e6..0cf75ada 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -772,16 +772,21 @@ fn theme( }; } PromptEvent::Validate => { - let theme_name = args.first().with_context(|| "Theme name not provided")?; - let theme = cx - .editor - .theme_loader - .load(theme_name) - .with_context(|| "Theme does not exist")?; - if !(true_color || theme.is_16_color()) { - bail!("Unsupported theme: theme requires true color support"); + if let Some(theme_name) = args.first() { + let theme = cx + .editor + .theme_loader + .load(theme_name) + .with_context(|| "Theme does not exist")?; + if !(true_color || theme.is_16_color()) { + bail!("Unsupported theme: theme requires true color support"); + } + cx.editor.set_theme(theme); + } else { + let name = cx.editor.theme.name().to_string(); + + cx.editor.set_status(name); } - cx.editor.set_theme(theme); } }; @@ -1866,7 +1871,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "theme", aliases: &[], - doc: "Change the editor theme.", + doc: "Change the editor theme (show current theme if no name specified).", fun: theme, completer: Some(completers::theme), }, |