Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Fix delete word not replacing text
Browse files Browse the repository at this point in the history
  • Loading branch information
aringenbach committed Oct 2, 2023
1 parent 90754f6 commit f2474c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/wysiwyg/src/composer_model/delete_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ where
node.offset_is_inside_node(current_offset, &direction);

// delete to the cursor
self.delete_to_cursor(current_position);
let update = self.delete_to_cursor(current_position);

// if we have stopped inside the node and we didn't start at whitespace, stop
if offset_is_inside_node && start_type != CharType::Whitespace {
return ComposerUpdate::keep();
return update;
}

// otherwise make a recursive call
let next_args = self.get_remove_word_arguments(&direction);
match next_args {
None => ComposerUpdate::keep(),
None => update,
Some(args) => {
let (location, next_type) = args;
let type_argument = if offset_is_inside_node {
Expand Down
7 changes: 7 additions & 0 deletions crates/wysiwyg/src/tests/test_deleting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,13 @@ fn backspace_mention_from_end() {
assert_eq!(restore_whitespace(&tx(&model)), "|");
}

#[test]
fn backspace_word_returns_replace_all_update() {
let mut model = cm("Some text with multiple words|");
let update = model.backspace_word();
assert!(matches!(update.text_update, TextUpdate::ReplaceAll(_)))
}

#[test]
fn delete_immutable_link_from_edge_of_link() {
let mut model = cm(
Expand Down

0 comments on commit f2474c4

Please sign in to comment.