aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/editor.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 0eb61308..adf0cdf3 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -38,7 +38,7 @@ use helix_core::{
use helix_core::{Position, Selection};
use helix_dap as dap;
-use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize};
+use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result<Duration, D::Error>
where
@@ -48,6 +48,18 @@ where
Ok(Duration::from_millis(millis))
}
+fn serialize_duration_millis<S>(duration: &Duration, serializer: S) -> Result<S::Ok, S::Error>
+where
+ S: Serializer,
+{
+ serializer.serialize_u64(
+ duration
+ .as_millis()
+ .try_into()
+ .map_err(|_| serde::ser::Error::custom("duration value overflowed u64"))?,
+ )
+}
+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct FilePickerConfig {
@@ -109,8 +121,12 @@ pub struct Config {
pub auto_pairs: AutoPairConfig,
/// Automatic auto-completion, automatically pop up without user trigger. Defaults to true.
pub auto_completion: bool,
- /// Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. Defaults to 400ms.
- #[serde(skip_serializing, deserialize_with = "deserialize_duration_millis")]
+ /// Time in milliseconds since last keypress before idle timers trigger.
+ /// Used for autocompletion, set to 0 for instant. Defaults to 400ms.
+ #[serde(
+ serialize_with = "serialize_duration_millis",
+ deserialize_with = "deserialize_duration_millis"
+ )]
pub idle_timeout: Duration,
pub completion_trigger_len: u8,
/// Whether to display infoboxes. Defaults to true.