diff --git a/Cargo.lock b/Cargo.lock index 24a1226fe..c2c05e91f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,6 +93,25 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "bincode" +version = "2.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f11ea1a0346b94ef188834a65c068a03aec181c94896d481d7a0a40d85b0ce95" +dependencies = [ + "bincode_derive", + "serde", +] + +[[package]] +name = "bincode_derive" +version = "2.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e30759b3b99a1b802a7a3aa21c85c3ded5c28e1c83170d82d70f08bbf7f3e4c" +dependencies = [ + "virtue", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -122,12 +141,6 @@ version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.4.0" @@ -1426,6 +1439,7 @@ version = "24.7.0" dependencies = [ "anyhow", "arc-swap", + "bincode", "chrono", "content_inspector", "crossterm", @@ -1451,7 +1465,6 @@ dependencies = [ "open", "pulldown-cmark", "same-file", - "rmp-serde", "serde", "serde_json", "signal-hook", @@ -1883,12 +1896,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - [[package]] name = "pathdiff" version = "0.2.1" @@ -2063,28 +2070,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" -[[package]] -name = "rmp" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" -dependencies = [ - "byteorder", - "num-traits", - "paste", -] - -[[package]] -name = "rmp-serde" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" -dependencies = [ - "byteorder", - "rmp", - "serde", -] - [[package]] name = "ropey" version = "1.6.1" @@ -2586,6 +2571,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "virtue" +version = "0.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dcc60c0624df774c82a0ef104151231d37da4962957d691c011c852b2473314" + [[package]] name = "walkdir" version = "2.4.0" diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index a488e45bd..6aedd3017 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -69,7 +69,7 @@ serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } # shada -rmp-serde = "1.1.2" +bincode = "2.0.0-rc.3" # ripgrep for global search grep-regex = "0.1.12" diff --git a/helix-term/src/shada.rs b/helix-term/src/shada.rs index 108ce036a..9dc890e7e 100644 --- a/helix-term/src/shada.rs +++ b/helix-term/src/shada.rs @@ -1,39 +1,36 @@ +use bincode::{encode_into_std_write, Decode, Encode}; use helix_loader::{shada_file, VERSION_AND_GIT_HASH}; -use helix_view::view::ViewPosition; -use rmp_serde::Serializer; -use serde::{Deserialize, Serialize}; +// use helix_view::view::ViewPosition; use std::{ fs::File, time::{SystemTime, UNIX_EPOCH}, }; // TODO: should this be non-exhaustive? -#[derive(Debug, Deserialize, Serialize)] -#[serde(rename = "H")] +#[derive(Debug, Encode, Decode)] struct Header { generator: String, version: String, - encoding: String, max_kbyte: u32, pid: u32, } // TODO: should this be non-exhaustive? -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Encode, Decode)] struct FilePosition { path: String, - position: ViewPosition, + // position: ViewPosition, } // TODO: should this be non-exhaustive? -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Encode, Decode)] enum EntryData { Header(Header), FilePosition(FilePosition), } // TODO: should this be non-exhaustive? -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Encode, Decode)] struct Entry { timestamp: u64, data: EntryData, @@ -52,9 +49,6 @@ fn generate_header() -> Entry { data: EntryData::Header(Header { generator: "helix".to_string(), version: VERSION_AND_GIT_HASH.to_string(), - // TODO: is this necessary? helix doesn't seem to expose an option - // for internal encoding like nvim does - encoding: "utf-8".to_string(), max_kbyte: 100, pid: std::process::id(), }), @@ -65,11 +59,10 @@ pub fn write_shada_file() { // TODO: merge existing file if exists // TODO: do something about this unwrap - let shada_file = File::create(shada_file()).unwrap(); - let mut serializer = Serializer::new(shada_file); + let mut shada_file = File::create(shada_file()).unwrap(); let header = generate_header(); // TODO: do something about this unwrap - header.serialize(&mut serializer).unwrap(); + encode_into_std_write(&header, &mut shada_file, bincode::config::standard()).unwrap(); } diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs index 9ebec0051..a229f01ea 100644 --- a/helix-view/src/view.rs +++ b/helix-view/src/view.rs @@ -18,8 +18,6 @@ use helix_core::{ VisualOffsetError::{PosAfterMaxRow, PosBeforeAnchorRow}, }; -use serde::{Deserialize, Serialize}; - use std::{ collections::{HashMap, VecDeque}, fmt, @@ -120,7 +118,7 @@ impl JumpList { } } -#[derive(Clone, Debug, PartialEq, Eq, Copy, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Copy, Default)] pub struct ViewPosition { pub anchor: usize, pub horizontal_offset: usize,