if (newStart == newEnd) continue;
void setStyleRanges (int[] newRanges, StyleRange[] newStyles) {	if (newStyles == null) {		styleCount = 0;		ranges = null;		styles = null;		return;	}		if (styleCount == 0) {		if (newRanges != null) {			ranges = new int[newRanges.length];			System.arraycopy(newRanges, 0, ranges, 0, ranges.length);		}		styles = new StyleRange[newStyles.length];		System.arraycopy(newStyles, 0, styles, 0, styles.length);		styleCount = newStyles.length;		return;	}	if (newRanges != null && ranges == null) {		ranges = new int[styles.length << 1];		for (int i = 0, j = 0; i < styleCount; i++) {			ranges[j++] = styles[i].start;			ranges[j++] = styles[i].length;		}	}	if (newRanges == null && ranges != null) {		newRanges = new int[newStyles.length << 1];		for (int i = 0, j = 0; i < newStyles.length; i++) {			newRanges[j++] = newStyles[i].start;			newRanges[j++] = newStyles[i].length;		}	}	if (ranges != null) {		int start = newRanges[0];		int rangeCount = styleCount << 1;		int modifyStart = getRangeIndex(start, -1, rangeCount);		if (modifyStart == rangeCount) {			if (newStyles.length + styleCount >= styles.length) {				int[] tmpRanges = new int[ranges.length + newRanges.length];				System.arraycopy(ranges, 0, tmpRanges, 0, ranges.length);				ranges = tmpRanges;				StyleRange[] tmpStyles = new StyleRange[styles.length + newStyles.length];				System.arraycopy(styles, 0, tmpStyles, 0, styles.length);				styles = tmpStyles;			}			System.arraycopy(newRanges, 0, ranges, rangeCount, newRanges.length);			System.arraycopy(newStyles, 0, styles, styleCount, newStyles.length);			styleCount += newStyles.length;			return;		}				int modifyEnd = modifyStart;		int[] mergeRanges = new int[6];		StyleRange[] mergeStyles = new StyleRange[3];		for (int i = 0; i < newRanges.length; i += 2) {			int newStart = newRanges[i];			int newEnd = newStart + newRanges[i + 1];			int modifyLast = 0, mergeCount = 0;			while (modifyEnd < rangeCount) {				if (newStart >= ranges[modifyStart] + ranges[modifyStart + 1]) modifyStart += 2;				if (ranges[modifyEnd] + ranges[modifyEnd + 1] > newEnd) break;				modifyEnd += 2;			}			if (ranges[modifyStart] < newStart && newStart < ranges[modifyStart] + ranges[modifyStart + 1]) {				mergeStyles[mergeCount >> 1] = styles[modifyStart >> 1];				mergeRanges[mergeCount] = ranges[modifyStart];				mergeRanges[mergeCount + 1] = newStart - ranges[modifyStart];								mergeCount += 2;			}			mergeStyles[mergeCount >> 1] = newStyles[i >> 1];			mergeRanges[mergeCount] = newStart;			mergeRanges[mergeCount + 1] = newRanges[i + 1];			mergeCount += 2;			if (modifyEnd < rangeCount && ranges[modifyEnd] < newEnd && newEnd < ranges[modifyEnd] + ranges[modifyEnd + 1]) {				mergeStyles[mergeCount >> 1] = styles[modifyEnd >> 1];				mergeRanges[mergeCount] = newEnd;				mergeRanges[mergeCount + 1] = ranges[modifyEnd] + ranges[modifyEnd + 1] - newEnd;				mergeCount += 2;				modifyLast = 2;			}			modifyEnd += modifyLast;			int grow = mergeCount - (modifyEnd - modifyStart);			if (rangeCount + grow >= ranges.length) {				int[] tmpRanges = new int[ranges.length + grow + (GROW << 1)];				System.arraycopy(ranges, 0, tmpRanges, 0, modifyStart);				StyleRange[] tmpStyles = new StyleRange[styles.length + (grow >> 1) + GROW];				System.arraycopy(styles, 0, tmpStyles, 0, modifyStart >> 1);				if (rangeCount > modifyEnd) {					System.arraycopy(ranges, modifyEnd, tmpRanges, modifyStart + mergeCount, rangeCount - modifyEnd);					System.arraycopy(styles, modifyEnd >> 1, tmpStyles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));				}				ranges = tmpRanges;				styles = tmpStyles;			} else {				if (rangeCount > modifyEnd) {					System.arraycopy(ranges, modifyEnd, ranges, modifyStart + mergeCount, rangeCount - modifyEnd);					System.arraycopy(styles, modifyEnd >> 1, styles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));				}			}			System.arraycopy(mergeRanges, 0, ranges, modifyStart, mergeCount);			System.arraycopy(mergeStyles, 0, styles, modifyStart >> 1, mergeCount >> 1);			rangeCount += grow;			styleCount += grow >> 1;			modifyStart = modifyEnd = modifyEnd + grow - modifyLast;		}			} else {		int start = newStyles[0].start;		int modifyStart = getRangeIndex(start, -1, styleCount);		if (modifyStart == styleCount) {			if (newStyles.length + styleCount >= styles.length) {				StyleRange[] tmpStyles = new StyleRange[styles.length + newStyles.length];				System.arraycopy(styles, 0, tmpStyles, 0, styles.length);				styles = tmpStyles;			}			System.arraycopy(newStyles, 0, styles, styleCount, newStyles.length);			styleCount += newStyles.length;			return;		}		int modifyEnd = modifyStart;		StyleRange[] mergeStyles = new StyleRange[3];		for (int i = 0; i < newStyles.length; i++) {			int newStart = newStyles[i].start;			int newEnd = newStart + newStyles[i].length;			int modifyLast = 0, mergeCount = 0;			while (modifyEnd < styleCount) {				if (newStart >= styles[modifyStart].start + styles[modifyStart].length) modifyStart++;				if (styles[modifyEnd].start + styles[modifyEnd].length > newEnd) break;				modifyEnd++;			}			if (styles[modifyStart].start < newStart && newStart < styles[modifyStart].start + styles[modifyStart].length) {				StyleRange style = mergeStyles[mergeCount++] = (StyleRange)styles[modifyStart].clone();				style.length = newStart - style.start;			}			mergeStyles[mergeCount++] = newStyles[i];			if (modifyEnd < styleCount && styles[modifyEnd].start < newEnd && newEnd < styles[modifyEnd].start + styles[modifyEnd].length) {				StyleRange style = mergeStyles[mergeCount++] = (StyleRange)styles[modifyEnd].clone();				style.start = newEnd;				style.length = styles[modifyEnd].start + styles[modifyEnd].length - newEnd;				modifyLast = 1;			}			modifyEnd += modifyLast;			int grow = mergeCount - (modifyEnd - modifyStart);			if (styleCount + grow >= styles.length) {				StyleRange[] tmpStyles = new StyleRange[styles.length + grow + GROW];				System.arraycopy(styles, 0, tmpStyles, 0, modifyStart);				if (styleCount > modifyEnd) {					System.arraycopy(styles, modifyEnd, tmpStyles, modifyStart + mergeCount, styleCount - modifyEnd);				}				styles = tmpStyles;			} else {				if (styleCount > modifyEnd) {					System.arraycopy(styles, modifyEnd, styles, modifyStart + mergeCount, styleCount - modifyEnd);				}			}			System.arraycopy(mergeStyles, 0, styles, modifyStart, mergeCount);			styleCount += grow;			modifyStart = modifyEnd = modifyEnd + grow - modifyLast;		}		}}