@@ -5,10 +5,7 @@ import android.text.SpannableStringBuilder
55import android.text.TextUtils
66import org.jsoup.Jsoup
77import org.jsoup.nodes.Document
8- import org.wordpress.aztec.spans.AztecParagraphStyle
9- import org.wordpress.aztec.spans.AztecVisualLinebreak
10- import org.wordpress.aztec.spans.EndOfParagraphMarker
11- import org.wordpress.aztec.spans.ParagraphSpan
8+ import org.wordpress.aztec.spans.*
129import java.util.regex.Matcher
1310import java.util.regex.Pattern
1411
@@ -350,9 +347,14 @@ object Format {
350347 text.insert(spanEnd, " \n " )
351348 }
352349
353- text.getSpans(spanStart, spanEnd, AztecVisualLinebreak ::class .java).forEach {
354- text.removeSpan(it)
350+ // remove visual newline marking around comment and line spans to add a space above and below them in source editor
351+ if (spanStart > 0 && (
352+ text.getSpans(spanStart - 1 , spanEnd, AztecFullWidthImageSpan ::class .java).isNotEmpty() ||
353+ text.getSpans(spanStart - 1 , spanEnd, CommentSpan ::class .java).isNotEmpty() ||
354+ text.getSpans(spanStart - 1 , spanEnd, AztecHorizontalLineSpan ::class .java).isNotEmpty())) {
355+ text.getSpans(spanStart, spanEnd, AztecVisualLinebreak ::class .java).forEach { text.removeSpan(it) }
355356 }
357+
356358 }
357359
358360 // we don't care about actual ParagraphSpan in calypso - paragraphs are made from double newline
0 commit comments