Bug 385117

Summary: Python indentation indents too often since recent update
Product: [Applications] kate Reporter: Maarten ter Huurne <maarten>
Component: indentationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: simonandric5
Priority: NOR    
Version: 17.08.1   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description Maarten ter Huurne 2017-09-27 00:58:57 UTC
I've been using Kate with Python projects for a long time, but since a recent update it hasn't been functioning well.

The problem is that it will often indent a line to line up with the line above it. For languages like C this would be desired, but since in Python the end of a block is identified by the indentation level decreasing, an editor should never change the indentation of an existing line, since it changes the meaning of the code being edited.

For example, if I start with this code fragment:

    if x == 0:
        foo()
    y = x

and I then add "+ 1" to the third line, Kate will indent it like this:

    if x == 0:
        foo()
        y = x + 1

which incorrectly pulls the third line into the if's body.
Comment 1 sunwebrw 2017-09-28 12:22:49 UTC
I also have 17.08.1 in Manjaro and can't confirm your case.
Comment 2 sunwebrw 2017-09-28 12:46:16 UTC
Is it possible that you wrote an example here(not tested in kate) but in fact have this experience https://bugs.kde.org/show_bug.cgi?id=384658 ?
Comment 3 Maarten ter Huurne 2017-09-28 18:32:46 UTC
I did test that exact fragment in Kate when I filed the bug. However, when I try to reproduce it now, Kate doesn't indent the third line. So there must be some yet unknown factor that makes this bad indentation trigger.

I created the fragment inside the larger source file that I was editing at that moment, so it is possible either the context is relevant or some unseen state in Kate matters.

The indent happened when I typed the '+', so not one of the letters mentioned in the other bug.

I expect the problem will occur again, since it wasn't the first time it happened when I filed the bug. When it does, I'll try to figure out what is relevant about the context or state to be able to reproduce this.
Comment 4 Dominik Haumann 2017-11-05 11:04:13 UTC
This is a regression in the indentation in the KTextEditor framework 5.38 and 5.39. This regression was introduced since we switched from the Qt Script to the Qt QML javascript implementation. Unfortunately, the Qt QML implementation still had issues which we did not catch early enough.

The good news is that if you upgrade your Qt version to Qt >= 5.9.1, then this crash is fixed. A workaround will also be available with KDE Frameworks 5.40 which should prevent the crash.

Sorry for the inconvenience!

*** This bug has been marked as a duplicate of bug 384404 ***