A simple CPU rendered GUI IDE experience.
bendy coding
bendn 4 weeks ago
parent ffc5af7 · commit 5e9c211
-rw-r--r--Cargo.toml5
-rw-r--r--src/edi.rs19
-rw-r--r--src/lsp.rs8
3 files changed, 24 insertions, 8 deletions
diff --git a/Cargo.toml b/Cargo.toml
index b8c5823..1d16e8f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@ run_times = "0.1.0"
array_chunks = "1.0.0"
rust-fsm = { git = "https://git.bendn.org/rust-fsm", features = ["diagram"] }
clipp = "0.1.0"
-diff-match-patch-rs = "0.5.1"
+diff-match-patch-rs = { git = "https://git.bendn.org/dmp" }
regex = "1.11.3"
tree-house = { version = "0.3.0", features = ["fixtures"] }
@@ -61,9 +61,8 @@ swizzle = "0.1.0"
walkdir = "2.5.0"
niri = { package = "niri-ipc", version = "25.11.0" }
libc = "0.2.180"
-serde_bencode = "0.2.4"
rustc-hash = "=2.1.1"
-serde_bencoded = "0.3.2"
+bendy = { version = "0.6.1", features = ["serde"] }
[profile.dev.package]
rust-analyzer.opt-level = 3
diff --git a/src/edi.rs b/src/edi.rs
index 6149acd..1b9baaa 100644
--- a/src/edi.rs
+++ b/src/edi.rs
@@ -89,6 +89,7 @@ pub struct Requests {
RequestError<SemanticTokensFullRequest>,
>,
pub diag: Rq<String, Option<String>, (), anyhow::Error>,
+ #[serde(skip)]
pub inlay: Rq<
Vec<InlayHint>,
Vec<InlayHint>,
@@ -120,7 +121,7 @@ pub struct Editor {
std::thread::JoinHandle<()>,
Option<Sender<Arc<Window>>>,
)>,
- #[serde(skip)]
+ // #[serde(skip)]
pub requests: Requests,
#[serde(skip)]
pub tree: Option<Vec<PathBuf>>,
@@ -194,7 +195,7 @@ impl Editor {
&& at.exists()
{
let x = std::fs::read(at).unwrap();
- let x = serde_bencoded::from_bytes::<Editor>(&x).unwrap();
+ let x = bendy::serde::from_bytes::<Editor>(&x).unwrap();
me = x;
loaded_state = true;
assert!(me.workspace.is_some());
@@ -1413,6 +1414,7 @@ impl Editor {
self.text.cursor.min(self.text.rope.len_chars());
self.mtime = Self::modify(self.origin.as_deref());
self.bar.last_action = "restored -> reloaded".into();
+ take(&mut self.requests);
self.hist.push(&self.text)
}
self.lsp = lsp;
@@ -1468,10 +1470,9 @@ impl Editor {
let cfgdir = cfgdir();
let p = cfgdir.join(format!("{hash:x}"));
std::fs::create_dir_all(&p)?;
- let b = serde_bencoded::to_vec::<Editor>(self)?;
+ let b = bendy::serde::to_bytes(&self).unwrap();
+ bendy::serde::from_bytes::<Editor>(&b)?;
std::fs::write(p.join(STORE), &b)?;
- serde_bencoded::from_bytes::<Editor>(&b)
- .expect("ensure roundtrips");
}
Ok(())
}
@@ -1545,3 +1546,11 @@ fn cfgdir() -> PathBuf {
.join("gracilaria")
}
const STORE: &str = "state.torrent";
+#[track_caller]
+fn rtt<T: serde::Serialize + serde::Deserialize<'static>>(
+ x: &T,
+) -> Result<T, bendy::serde::Error> {
+ bendy::serde::from_bytes::<T>(
+ bendy::serde::to_bytes(x).unwrap().leak(),
+ )
+}
diff --git a/src/lsp.rs b/src/lsp.rs
index 963109c..06c3447 100644
--- a/src/lsp.rs
+++ b/src/lsp.rs
@@ -1090,12 +1090,20 @@ impl<R: Request> std::fmt::Debug for RequestError<R> {
fn none<T>() ->Option<T> {
None
}
+impl<T: Clone,R,D,E> Clone for Rq<T, R, D, E> {
+ fn clone(&self) -> Self {
+ Self { result: self.result.clone(), request: None }
+ }
+}
#[derive(Debug, serde_derive::Serialize, serde_derive::Deserialize)]
+
pub struct Rq<T, R, D = (), E = RequestError<R>> {
+ #[serde(skip_serializing_if = "Option::is_none", default = "none")]
pub result: Option<T>,
#[serde(skip, default = "none")]
pub request: Option<(AbortOnDropHandle<Result<R, E>>, D)>,
}
+
pub type RqS<T, R: Request, D = ()> = Rq<T, R::Result, D, RequestError<R>>;
impl<T, R, D, E> Default for Rq<T, R, D, E> {
fn default() -> Self {