Skip to content

Commit 83dd297

Browse files
committed
Removing visual linebreaks only around comments/newline
1 parent 73b5511 commit 83dd297

File tree

1 file changed

+8
-6
lines changed
  • aztec/src/main/kotlin/org/wordpress/aztec/source

1 file changed

+8
-6
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import android.text.SpannableStringBuilder
55
import android.text.TextUtils
66
import org.jsoup.Jsoup
77
import 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.*
129
import java.util.regex.Matcher
1310
import 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

Comments
 (0)