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

Fix delete word not replacing text #833

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading