@Override
    public void handleAutoCloseElementEnd(
            final char[] buffer,
            final int nameOffset, final int nameLen,
            final int line, final int col)
            throws ParseException {

        if (!this.insideAllSelectorMatchingBlock) {

            this.someSelectorsMatch = false;
            for (int i = 0; i < this.selectorsLen; i++) {
                // We use the flags indicating past matches to recompute new ones
                this.selectorMatches[i] = this.matchingMarkupLevelsPerSelector[i] <= this.markupLevel;
                if (this.selectorMatches[i]) {
                    this.someSelectorsMatch = true;
                }
            }

            for (int i = 0; i < this.selectorsLen; i++) {
                if (this.matchingMarkupLevelsPerSelector[i] == this.markupLevel) {
                    this.insideAllSelectorMatchingBlock = false;
                    this.matchingMarkupLevelsPerSelector[i] = Integer.MAX_VALUE;
                }
            }

            if (this.someSelectorsMatch) {
                this.selectedHandler.handleAutoCloseElementEnd(buffer, nameOffset, nameLen, line, col);
                unmarkCurrentSelection();
                return;
            }

            unmarkCurrentSelection();
            this.nonSelectedHandler.handleAutoCloseElementEnd(buffer, nameOffset, nameLen, line, col);
            return;

        }

        for (int i = 0; i < this.selectorsLen; i++) {
            if (this.matchingMarkupLevelsPerSelector[i] == this.markupLevel) {
                this.insideAllSelectorMatchingBlock = false;
                this.matchingMarkupLevelsPerSelector[i] = Integer.MAX_VALUE;
            }
        }


        this.selectedHandler.handleAutoCloseElementEnd(buffer, nameOffset, nameLen, line, col);
        unmarkCurrentSelection();

    }