Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/commands.rs')
| -rw-r--r-- | helix-term/src/commands.rs | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index bd489d3e..f5870109 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4146,7 +4146,7 @@ pub mod insert { auto_pairs .as_ref() .and_then(|ap| { - auto_pairs::hook(text, range, c, ap) + auto_pairs::hook_insert(text, range, c, ap) .map(|(change, range)| (change, Some(range))) .or(Some(insert_char(*range, c))) }) @@ -4406,11 +4406,13 @@ pub mod insert { let indent_width = doc.indent_width(); let auto_pairs = doc.auto_pairs(cx.editor); - let transaction = - Transaction::delete_by_selection(doc.text(), doc.selection(view.id), |range| { + let transaction = Transaction::delete_by_and_with_selection( + doc.text(), + doc.selection(view.id), + |range| { let pos = range.cursor(text); if pos == 0 { - return (pos, pos); + return ((pos, pos), None); } let line_start_pos = text.line_to_char(range.cursor_line(text)); // consider to delete by indent level if all characters before `pos` are indent units. @@ -4418,7 +4420,10 @@ pub mod insert { if !fragment.is_empty() && fragment.chars().all(|ch| ch == ' ' || ch == '\t') { if text.get_char(pos.saturating_sub(1)) == Some('\t') { // fast path, delete one char - (graphemes::nth_prev_grapheme_boundary(text, pos, 1), pos) + ( + (graphemes::nth_prev_grapheme_boundary(text, pos, 1), pos), + None, + ) } else { let width: usize = fragment .chars() @@ -4445,7 +4450,7 @@ pub mod insert { _ => break, } } - (start, pos) // delete! + ((start, pos), None) // delete! } } else { match ( @@ -4461,18 +4466,26 @@ pub mod insert { // delete both autopaired characters { ( - graphemes::nth_prev_grapheme_boundary(text, pos, count), - graphemes::nth_next_grapheme_boundary(text, pos, count), + ( + graphemes::nth_prev_grapheme_boundary(text, pos, count), + graphemes::nth_next_grapheme_boundary(text, pos, count), + ), + None, ) } _ => // delete 1 char { - (graphemes::nth_prev_grapheme_boundary(text, pos, count), pos) + ( + (graphemes::nth_prev_grapheme_boundary(text, pos, count), pos), + None, + ) } } } - }); + }, + ); + let (view, doc) = current!(cx.editor); doc.apply(&transaction, view.id); } |