@@ -1096,51 +1096,7 @@ class BlockFormatter(editor: AztecText,
10961096 }
10971097
10981098 fun containsPreformat (selStart : Int = selectionStart, selEnd : Int = selectionEnd): Boolean {
1099- val lines = TextUtils .split(editableText.toString(), " \n " )
1100- val list = ArrayList <Int >()
1101-
1102- for (i in lines.indices) {
1103- val lineStart = (0 until i).sumBy { lines[it].length + 1 }
1104- val lineEnd = lineStart + lines[i].length
1105-
1106- if (lineStart >= lineEnd) {
1107- continue
1108- }
1109-
1110- /* *
1111- * lineStart >= selStart && selEnd >= lineEnd // single line, current entirely selected OR
1112- * multiple lines (before and/or after), current entirely selected
1113- * lineStart <= selEnd && selEnd <= lineEnd // single line, current partially or entirely selected OR
1114- * multiple lines (after), current partially or entirely selected
1115- * lineStart <= selStart && selStart <= lineEnd // single line, current partially or entirely selected OR
1116- * multiple lines (before), current partially or entirely selected
1117- */
1118- if ((lineStart >= selStart && selEnd >= lineEnd)
1119- || (selEnd in lineStart.. lineEnd)
1120- || (selStart in lineStart.. lineEnd)) {
1121- list.add(i)
1122- }
1123- }
1124-
1125- if (list.isEmpty()) return false
1126-
1127- return list.any { containsPreformat(it) }
1128- }
1129-
1130- fun containsPreformat (index : Int ): Boolean {
1131- val lines = TextUtils .split(editableText.toString(), " \n " )
1132- if (index < 0 || index >= lines.size) {
1133- return false
1134- }
1135-
1136- val start = (0 until index).sumBy { lines[it].length + 1 }
1137- val end = start + lines[index].length
1138-
1139- if (start >= end) {
1140- return false
1141- }
1142-
1143- val spans = editableText.getSpans(start, end, AztecPreformatSpan ::class .java)
1099+ val spans = editableText.getSpans(selStart, selEnd, AztecPreformatSpan ::class .java)
11441100 return spans.isNotEmpty()
11451101 }
11461102
0 commit comments