@@ -8,6 +8,7 @@ use super::*;
8use helix_core::{encoding, shellwords::Shellwords};
8use helix_core::{encoding, shellwords::Shellwords};
9use helix_view::document::DEFAULT_LANGUAGE_NAME;
9use helix_view::document::DEFAULT_LANGUAGE_NAME;
10use helix_view::editor::{Action, CloseError, ConfigEvent};
10use helix_view::editor::{Action, CloseError, ConfigEvent};
11+use serde_json::Value;
11use ui::completers::{self, Completer};
12use ui::completers::{self, Completer};
13#[derive(Clone)]
14#[derive(Clone)]
@@ -1764,7 +1765,7 @@ fn set_option(
1765 *value = if value.is_string() {
1766 *value = if value.is_string() {
1766 // JSON strings require quotes, so we can't .parse() directly
1767 // JSON strings require quotes, so we can't .parse() directly
1767− serde_json::Value::String(arg.to_string())
1768+ Value::String(arg.to_string())
1768 } else {
1769 } else {
1769 arg.parse().map_err(field_error)?
1770 arg.parse().map_err(field_error)?
@@ -1800,29 +1801,21 @@ fn toggle_option(
1800 let pointer = format!("/{}", key.replace('.', "/"));
1801 let pointer = format!("/{}", key.replace('.', "/"));
1801 let value = config.pointer_mut(&pointer).ok_or_else(key_error)?;
1802 let value = config.pointer_mut(&pointer).ok_or_else(key_error)?;
1803− *value = match value.as_bool() {
1804+ *value = match value {
1804− Some(value) => {
1805+ Value::Bool(ref value) => {
1805 ensure!(
1806 ensure!(
1806 args.len() == 1,
1807 args.len() == 1,
1807 "Bad arguments. For boolean configurations use: `:toggle key`"
1808 "Bad arguments. For boolean configurations use: `:toggle key`"
1809− serde_json::Value::Bool(!value)
1810+ Value::Bool(!value)
1811− None => {
1812+ Value::String(ref value) => {
1812 ensure!(
1813 ensure!(
1813 args.len() > 2,
1814 args.len() > 2,
1814− "Bad arguments. For non-boolean configurations use: `:toggle key val1 val2 ...`",
1815+ "Bad arguments. For string configurations use: `:toggle key val1 val2 ...`",
1818− "Bad configuration. Cannot cycle non-string configurations"
1823− .expect("programming error: should have been ensured before");
1825− serde_json::Value::String(
1818+ Value::String(
1826 args[1..]
1819 args[1..]
1828 .skip_while(|e| *e != value)
1821 .skip_while(|e| *e != value)
@@ -1831,6 +1824,9 @@ fn toggle_option(
1831 .to_string(),
1824 .to_string(),
1827+ Value::Null | Value::Object(_) | Value::Array(_) | Value::Number(_) => {
1828+ anyhow::bail!("Configuration {key} does not support toggle yet")
1836 let status = format!("'{key}' is now set to {value}");
1832 let status = format!("'{key}' is now set to {value}");