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

Commit

Permalink
Remove NBSP chars in replace_text for empty paragraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed Jan 31, 2024
1 parent f0d503e commit ffc6f8b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/wysiwyg/src/composer_model/replace_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ where
let mut slices = text_string.split('\n').peekable();
while let Some(slice) = slices.next() {
let (s, e) = self.safe_selection();
if !slice.is_empty() {
if !slice.is_empty() && slice != "\u{A0}" {
self.do_replace_text_in(S::from(slice), s, e);
}
if slices.peek().is_some() {
Expand Down
15 changes: 15 additions & 0 deletions crates/wysiwyg/src/tests/test_characters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,21 @@ fn multiple_spaces_between_text() {
assert_eq!(tx(&model), "abc  def ghi   jkl|");
}

#[test]
fn replacing_text_with_empty_paragraphs_removes_nbsps_from_them() {
let mut model = cm("|");
replace_text(&mut model, "1\n\u{A0}\n2");
assert_eq!(
model.to_tree().to_string(),
r#"
├>p
│ └>"1"
├>p
└>p
└>"2"
"#);
}

#[test]
fn typing_html_does_not_break_anything() {
let mut model = cm("|");
Expand Down

0 comments on commit ffc6f8b

Please sign in to comment.