if (bidi != null && (paintX == 0)) { paintX = XINSET; }
void drawLineSelectionBackground(String line, int lineOffset, StyleRange[] styles, int paintY, GC gc, FontData currentFont, StyledTextBidi bidi) {	int lineLength = line.length();	int paintX;	int selectionBackgroundWidth = -1;	int selectionStart = Math.max(0, selection.x - lineOffset);	int selectionEnd = selection.y - lineOffset;	int selectionLength = selectionEnd - selectionStart;	if (selectionEnd == selectionStart || selectionEnd < 0 || selectionStart > lineLength) {		return;	}	if (bidi != null) {		paintX = bidiTextWidth(line, 0, selectionStart, 0, bidi);		}	else {		paintX = textWidth(line, lineOffset, 0, selectionStart, filterLineStyles(styles), 0, gc, currentFont);		}	// selection extends past end of line?	if (selectionEnd > lineLength) {		if ((getStyle() & SWT.FULL_SELECTION) != 0) {			// use the greater of the client area width and the content 			// width. fixes 1G8IYRD			selectionBackgroundWidth = Math.max(getClientArea().width, lineCache.getWidth());		}		else {			selectionLength = lineLength - selectionStart;		}	}	gc.setBackground(getSelectionBackground());	gc.setForeground(getSelectionForeground());	if (selectionBackgroundWidth == -1) {		boolean isWrappedLine = false;		if (wordWrap) {			int lineEnd = lineOffset + lineLength;			int lineIndex = content.getLineAtOffset(lineEnd);			// is the start offset of the next line the same as the end 			// offset of this line?						if (lineIndex < content.getLineCount() - 1 &&				content.getOffsetAtLine(lineIndex + 1) == lineEnd) {				isWrappedLine = true;			}		}		if (bidi != null) {			selectionBackgroundWidth = bidiTextWidth(line, selectionStart, selectionLength, paintX, bidi);		}		else {			selectionBackgroundWidth = textWidth(line, lineOffset, selectionStart, selectionLength, styles, paintX, gc, currentFont);		}		if (selectionBackgroundWidth < 0) {			// width can be negative when in R2L bidi segment			paintX += selectionBackgroundWidth;			selectionBackgroundWidth *= -1;		}		if (selectionEnd > lineLength && isWrappedLine == false) {			selectionEnd = selectionStart + selectionLength;			// if the selection extends past this line, render an additional 			// whitespace background at the end of the line to represent the 			// selected line break			if (bidi != null && selectionEnd > 0 && bidi.isRightToLeft(selectionEnd - 1)) {				int lineEndX = bidi.getTextWidth();				gc.fillRectangle(lineEndX - horizontalScrollOffset, paintY, lineEndSpaceWidth, lineHeight);			}			else {				selectionBackgroundWidth += lineEndSpaceWidth;			}		}	}		// fill the background first since expanded tabs are not 	// drawn as spaces. tabs just move the draw position. 	gc.fillRectangle(paintX - horizontalScrollOffset, paintY, selectionBackgroundWidth, lineHeight);}