--- Comment #14 from Janek Bevendorff <> ---
I played a little with the ktexteditor code. The culprit for the C-style
indenter is this part (line 774):

    } else if (firstPos == column - 1 && c == '}') {
        var indentation = findLeftBrace(line, firstPos);
        if (indentation == -1)
            indentation = -2;
        return indentation;

When I manually enter "{}", then firstPos is 4 and column is 6. However,
when using automatic bracket completion, my cursor is at 5, so the
condition is true and findLeftBrace() is called which retrieves a cursor
to the preceding brace like that:

var cursor = document.anchor(line, column, '{');

But since the cursor is before the insert position, this always results
in a (1, 0) cursor and therefore always unindents the line. My fix would
be to extend the initial check with one more condition:

} else if (firstPos == column - 1 && c == '}' &&
           document.charAt(line, firstPos) == '}') {

This would simply check if the inserted character is actually where the
cursor is. If not, it was probably inserted automatically.

The C++/boost indenter seems to be a lot more complex and I haven't
looked into that issue yet.

You are receiving this mail because:
You are watching all bug changes.

Reply via email to