diff --git a/platforms/ios/lib/WysiwygComposer/Sources/WysiwygComposer/Tools/StringDiffer.swift b/platforms/ios/lib/WysiwygComposer/Sources/WysiwygComposer/Tools/StringDiffer.swift index b19b97306..81322d56a 100644 --- a/platforms/ios/lib/WysiwygComposer/Sources/WysiwygComposer/Tools/StringDiffer.swift +++ b/platforms/ios/lib/WysiwygComposer/Sources/WysiwygComposer/Tools/StringDiffer.swift @@ -117,17 +117,7 @@ private struct StringDiff { private extension String { /// Converts all whitespaces to NBSP to avoid diffs caused by HTML translations. var withNBSP: String { - String(map { $0.isWhitespace ? Character.nbsp : $0 }).trailingTrimmed - } - - var trailingTrimmed: String { - var view = self[...] - - while view.last?.isWhitespace == true || view.last?.isNewline == true { - view = view.dropLast() - } - - return String(view) + String(map { $0.isWhitespace ? Character.nbsp : $0 }) } /// Computes the diff from provided string to self. Outputs UTF16 locations and lengths. diff --git a/platforms/ios/lib/WysiwygComposer/Tests/WysiwygComposerTests/Tools/StringDifferTests.swift b/platforms/ios/lib/WysiwygComposer/Tests/WysiwygComposerTests/Tools/StringDifferTests.swift index 7e9b66cae..4a42e4b8e 100644 --- a/platforms/ios/lib/WysiwygComposer/Tests/WysiwygComposerTests/Tools/StringDifferTests.swift +++ b/platforms/ios/lib/WysiwygComposer/Tests/WysiwygComposerTests/Tools/StringDifferTests.swift @@ -81,6 +81,11 @@ final class StringDifferTests: XCTestCase { XCTAssertEqual(try StringDiffer.replacement(from: " \u{00A0} text", to: " \u{00A0} test"), .init(location: 5, length: 1, text: "s")) } + + func testDoubleSpaceDotConversion() throws { + XCTAssertEqual(try StringDiffer.replacement(from: "a ", to: "a."), + .init(location: 1, length: 2, text: ".")) + } } private extension CharacterSet {