private IntRange scanBackwards(String text, int pos, char openChar, char closeChar) {
		int start = -1;
		int end = pos;
		int balance = 1;
		int open;
		int close;
		boolean remaining = true;
		do {
			open = text.lastIndexOf(openChar, pos - 1);
			close = text.lastIndexOf(closeChar, pos - 1);

			if (open > close)
				balance--;
			else if (close != -1 && close < pos)
				balance++;
			else
				return null;

			// Balance solved
			if (balance == 0) {
				start = open;
				break;
			}

			// Not solved, continue scanning by setting the cut-off for backwards scan
			// to the next closest item of the open/close character matches.
			int next = Math.max(open, close);

			// If the next position is the same, or beyond the current position
			// then that means we have exhausted all matches, and the balance is not solved.
			if (next >= pos)
				remaining = false;
			pos = next;
		} while (remaining);

		// Start found? Create range.
		return (start >= 0) ? new IntRange(start, end) : null;
	}
@param paragraph
		Paragraph index, which is {@code line - 1}.

@return {@code true} when the line belongs to the {@link #getRange() selected bracket pair range}.
recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/bracket/SelectedBracketTracking.java