From 09bf5c627dcab03e06890ff303c79fbe81eb9634 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Fri, 14 Jun 2024 21:56:44 -0700 Subject: [PATCH] feat: Replace jumprope with crop --- Cargo.toml | 2 +- src/file.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d4c073d..d045a60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,10 @@ edition = "2021" async-recursion = "1.1.1" chrono = "0.4.38" clap = "4.5.4" +crop = "0.4.2" dunce = "1.0.4" ignore = "0.4.22" java-properties = "2.0.0" -jumprope = "1.1.2" path-slash = "0.2.1" rpassword = "7.3.1" serde = { version = "1.0.203", features = ["derive"] } diff --git a/src/file.rs b/src/file.rs index efb5a52..2c1a132 100644 --- a/src/file.rs +++ b/src/file.rs @@ -16,15 +16,15 @@ use crate::chat::*; use crate::user::*; use crate::util::*; -use jumprope::{JumpRope, JumpRopeBuf}; +use crop::Rope; use std::collections::HashMap; use std::io::Write; #[derive(Debug)] pub struct File { - path: String, // absolute path - chat: Chat, // messages in this file - view: Option, // the file view + path: String, // absolute path + chat: Chat, // messages in this file + view: Option, // the file view } impl File { @@ -51,7 +51,7 @@ impl File { return; } let content = read_to_string(&self.path); - self.view = Some(JumpRopeBuf::from(content)); + self.view = Some(Rope::from(content)); } pub fn update(&mut self, add_or_delete: &String, beg: usize, end: usize, contents: &String) { @@ -63,7 +63,7 @@ impl File { view.insert(beg, &contents); } "delete" => { - view.remove(beg..end); + view.delete(beg..end); } _ => { unreachable!()