Skip to content

Commit

Permalink
completed bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
curlpipe committed Sep 8, 2024
1 parent dc0dc88 commit b899813
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
28 changes: 12 additions & 16 deletions .todo.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ox"
version = "0.4.5"
version = "0.4.6"
edition = "2021"
authors = ["Curlpipe <[email protected]>"]
description = "A Rust powered text editor."
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 34 additions & 0 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down

0 comments on commit b899813

Please sign in to comment.