on master help sign in
make :toggle-option print the new value (#6774)

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

commit7706ff77eb8aea9471af822355cad337707b9fc5 authorAleksey Kuznetsov <zummenix@gmail.com> dateSun 16 Apr 2023, 23:44 (4 years ago) parent7607727
1 file changed+6−4
helix-term/src/commands/typed.rs+6−4
helix-term/src/commands/typed.rs+6−4
@@ -1770,12 +1770,12 @@ fn toggle_option(
17701770 let pointer = format!("/{}", key.replace('.', "/"));
17711771 let value = config.pointer_mut(&pointer).ok_or_else(key_error)?;
17721772
1773− if let Value::Bool(b) = *value {
1774− *value = Value::Bool(!b);
1775− } else {
1773+ let Value::Bool(old_value) = *value else {
17761774 anyhow::bail!("Key `{}` is not toggle-able", key)
1777− }
1775+ };
17781776
1777+ let new_value = !old_value;
1778+ *value = Value::Bool(new_value);
17791779 // This unwrap should never fail because we only replace one boolean value
17801780 // with another, maintaining a valid json config
17811781 let config = serde_json::from_value(config).unwrap();
@@ -1784,6 +1784,8 @@ fn toggle_option(
17841784 .config_events
17851785 .0
17861786 .send(ConfigEvent::Update(config))?;
1787+ cx.editor
1788+ .set_status(format!("Option `{}` is now set to `{}`", key, new_value));
17871789 Ok(())
17881790}
17891791