matrix-org / matrix-rich-text-editor

Matrix Rich Text Editor
https://matrix-org.github.io/matrix-rich-text-editor/
Apache License 2.0
82 stars 19 forks source link

Fix a couple of bug's with isContentEmpty in Swift. #957

Closed pixlwave closed 3 months ago

pixlwave commented 3 months ago

The first bug is caused by typing a ` resulting in the model containing whilst the text view only contains the single space inserted by the user. Deleting that space leaves the model with ` which can't be deleted as the text view is now empty.

Discussed this with @Velin92 and we concluded the simplest fix for now was what this PR does, although it doesn't help when typing a single space for a new item in a list or as the first line in a quote, where you can see the same behaviour with an extra space in the model compared to the text view.

The second bug is caused by writing a multi-line paragraph and then deleting it. It leaves a single empty paragraph within the model (and there are tests in Rust to ensure this is the case). In this instance we can check for a \n character which isn't valid HTML and ignore it.

Fixes both issues mentioned in https://github.com/element-hq/element-x-ios/issues/2538

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud