Skip to content

Commit

Permalink
fix: fixing delete backwards
Browse files Browse the repository at this point in the history
  • Loading branch information
wllfaria committed May 27, 2024
1 parent 8a4b8f4 commit 6844054
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/src/default_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ pub static DEFAULT_CONFIG: &str = r##"
"Backspace" = "DeletePreviousChar"
"Esc" = { EnterMode = "Normal" }
"C-c" = { EnterMode = "Normal" }
"C-W" = "DeleteBack"
"C-w" = "DeleteBack"
"##;
5 changes: 3 additions & 2 deletions reqtui/src/text_object/text_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl TextObject<Write> {
let start_idx = self.content.line_to_char(cursor.row()).add(cursor.col());
let mut end_idx = start_idx.saturating_sub(1);

if let Some(initial_char) = self.content.get_char(start_idx) {
if let Some(initial_char) = self.content.get_char(start_idx.saturating_sub(1)) {
for _ in (0..start_idx.saturating_sub(1)).rev() {
let char = self.content.char(end_idx);
match (initial_char.is_alphanumeric(), char.is_alphanumeric()) {
Expand All @@ -352,7 +352,8 @@ impl TextObject<Write> {
}
};

end_idx.sub(start_idx)
self.content.try_remove(end_idx.add(1)..start_idx).ok();
start_idx.sub(end_idx.add(1))
}

pub fn insert_line_below(&mut self, cursor: &Cursor, tree: Option<&Tree>) {
Expand Down

0 comments on commit 6844054

Please sign in to comment.