aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kuznetsov2023-04-16 18:44:12 +0000
committerGitHub2023-04-16 18:44:12 +0000
commit7706ff77eb8aea9471af822355cad337707b9fc5 (patch)
tree63c6291a841c803073a13b4a55fdd76169c61f9e
parent7607727483dbc6461749e3c2d9b9305431eb8fb2 (diff)
make :toggle-option print the new value (#6774)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
-rw-r--r--helix-term/src/commands/typed.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 3c954d20..eb5c156f 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -1770,12 +1770,12 @@ fn toggle_option(
let pointer = format!("/{}", key.replace('.', "/"));
let value = config.pointer_mut(&pointer).ok_or_else(key_error)?;
- if let Value::Bool(b) = *value {
- *value = Value::Bool(!b);
- } else {
+ let Value::Bool(old_value) = *value else {
anyhow::bail!("Key `{}` is not toggle-able", key)
- }
+ };
+ let new_value = !old_value;
+ *value = Value::Bool(new_value);
// This unwrap should never fail because we only replace one boolean value
// with another, maintaining a valid json config
let config = serde_json::from_value(config).unwrap();
@@ -1784,6 +1784,8 @@ fn toggle_option(
.config_events
.0
.send(ConfigEvent::Update(config))?;
+ cx.editor
+ .set_status(format!("Option `{}` is now set to `{}`", key, new_value));
Ok(())
}