@@ -3,8 +3,8 @@ use helix_core::{
33 movement::{self, Direction},
44 object, pos_at_coords,
55 regex::{self, Regex},
6− register, search, selection, Change, ChangeSet, Position, Range, Rope, RopeSlice, Selection,
7− SmallVec, Tendril, Transaction,
6+ register, search, selection, words, Change, ChangeSet, Position, Range, Rope, RopeSlice,
7+ Selection, SmallVec, Tendril, Transaction,
88};
99
1010use helix_view::{
@@ -1782,7 +1782,6 @@ pub mod insert {
17821782
17831783 pub fn delete_char_forward(cx: &mut Context) {
17841784 let count = cx.count;
1785− let doc = cx.doc();
17861785 let (view, doc) = cx.current();
17871786 let text = doc.text().slice(..);
17881787 let transaction =
@@ -1795,6 +1794,21 @@ pub mod insert {
17951794 });
17961795 doc.apply(&transaction, view.id);
17971796 }
1797+
1798+ pub fn delete_word_backward(cx: &mut Context) {
1799+ let count = cx.count;
1800+ let (view, doc) = cx.current();
1801+ let text = doc.text().slice(..);
1802+ let transaction =
1803+ Transaction::change_by_selection(doc.text(), doc.selection(view.id), |range| {
1804+ (
1805+ words::nth_prev_word_boundary(text, range.head, count),
1806+ range.head,
1807+ None,
1808+ )
1809+ });
1810+ doc.apply(&transaction, view.id);
1811+ }
17981812}
17991813
18001814// Undo / Redo