Skip to content

Commit

Permalink
feat: Replace jumprope with crop
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 15, 2024
1 parent f8513f2 commit 09bf5c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
12 changes: 6 additions & 6 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<JumpRopeBuf>, // the file view
path: String, // absolute path
chat: Chat, // messages in this file
view: Option<Rope>, // the file view
}

impl File {
Expand All @@ -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) {
Expand All @@ -63,7 +63,7 @@ impl File {
view.insert(beg, &contents);
}
"delete" => {
view.remove(beg..end);
view.delete(beg..end);
}
_ => {
unreachable!()
Expand Down

0 comments on commit 09bf5c6

Please sign in to comment.