From b899813069b643b5efcedde0e5a39c25267ff4f6 Mon Sep 17 00:00:00 2001 From: Luke <11898833+curlpipe@users.noreply.github.com> Date: Sun, 8 Sep 2024 18:30:15 +0100 Subject: [PATCH] completed bug fixes --- .todo.md | 28 ++++++++++++---------------- Cargo.toml | 4 ++-- src/config.rs | 4 ++-- src/editor.rs | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/.todo.md b/.todo.md index 8829a955..28c9be40 100644 --- a/.todo.md +++ b/.todo.md @@ -1,19 +1,3 @@ -- [ ] General bug fixes - - [ ] Fix multi spaces not registering as tabs* - 8th - - [ ] Find out where tab info goes and how it's used - - [ ] Show as tabs but be spaces on the backend - - [X] Also investigate the cursor being able to jump out of bounds after a tab character at the end of a line - - [ ] Cursor movement improvement - 8th - - [ ] Fully understand the desired behaviour - - [ ] Where is this activity defined? - - [ ] Play around with caching original x position and trying to restore it - - [X] Update bulit-in help message and greeting message - - [X] Fix status line duplication issues - - [X] Search and replace needs to stop crashing due to syntax highlighting update - - [X] Search and replace needs to hide cursor - - [X] Replace command needs to update syntax - - [X] Undo / Redo need to be committed more* - - [X] Search needs to break beyond what has been loaded into buffer* - [ ] Config and documentation improvement - [ ] Look at old ox.ron config - add anything that is missing in new ox - [ ] Allow reloading of config file @@ -56,4 +40,16 @@ - [ ] Implement code prettification infrastructure - [ ] Autocomplete - [ ] Implement code autocomplete infrastructure +- [X] General bug fixes + - [X] Update bulit-in help message and greeting message + - [X] Fix status line duplication issues + - [X] Search and replace needs to stop crashing due to syntax highlighting update + - [X] Search and replace needs to hide cursor + - [X] Replace command needs to update syntax + - [X] Undo / Redo need to be committed more* + - [X] Search needs to break beyond what has been loaded into buffer* + - [X] Traverse over space groups as per tab width* + - [X] Cursor movement improvement + - [X] Fix incorrect behaviour on deletion of space tabs + - [X] Fix undo / redo not updating syntax highlighting diff --git a/Cargo.toml b/Cargo.toml index 2b3cdf4f..b1a046ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ox" -version = "0.4.5" +version = "0.4.6" edition = "2021" authors = ["Curlpipe <11898833+curlpipe@users.noreply.github.com>"] description = "A Rust powered text editor." @@ -28,7 +28,7 @@ assets = [ alinio = "0.2.1" crossterm = "0.27.0" jargon-args = "0.2.7" -kaolinite = "0.9.2" +kaolinite = "0.9.5" mlua = { version = "0.9.9", features = ["lua54", "vendored"] } quick-error = "2.0.1" shellexpand = "3.1.0" diff --git a/src/config.rs b/src/config.rs index 7ce6b5a0..e1b9f1b6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1041,14 +1041,14 @@ impl LuaUserData for Editor { Ok(()) }); methods.add_method_mut("undo", |_, editor, ()| { - if let Err(err) = editor.doc_mut().undo() { + if let Err(err) = editor.undo() { editor.feedback = Feedback::Error(err.to_string()); } update_highlighter(editor); Ok(()) }); methods.add_method_mut("redo", |_, editor, ()| { - if let Err(err) = editor.doc_mut().redo() { + if let Err(err) = editor.redo() { editor.feedback = Feedback::Error(err.to_string()); } update_highlighter(editor); diff --git a/src/editor.rs b/src/editor.rs index 0ec5da21..9c50c1b3 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -777,6 +777,40 @@ impl Editor { } } + /// Perform redo action + pub fn redo(&mut self) -> Result<()> { + let result = Ok(self.doc_mut().redo()?); + let mut affected_lines = vec![]; + if let Some(patch) = self.doc().event_mgmt.undo.last() { + for event in patch { + affected_lines.push(event.clone().loc().y); + } + } + affected_lines.sort(); + affected_lines.dedup(); + for line in affected_lines { + self.highlighter[self.ptr].edit(line, &self.doc[self.ptr].lines[line]); + } + result + } + + /// Perform undo action + pub fn undo(&mut self) -> Result<()> { + let result = Ok(self.doc_mut().undo()?); + let mut affected_lines = vec![]; + if let Some(patch) = self.doc().event_mgmt.redo.last() { + for event in patch { + affected_lines.push(event.clone().loc().y); + } + } + affected_lines.sort(); + affected_lines.dedup(); + for line in affected_lines { + self.highlighter[self.ptr].edit(line, &self.doc[self.ptr].lines[line]); + } + result + } + /// save the document to the disk pub fn save(&mut self) -> Result<()> { self.doc_mut().save()?;