Bug 299836

Summary: Unindenting code sometimes doesn't trigger reparse
Product: [Developer tools] kdev-python Reporter: Nicolás Alvarez <nalvarez>
Component: Language supportAssignee: Sven Brauch <mail>
Status: RESOLVED FIXED    
Severity: normal CC: antonis+kdebugs
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In:

Description Nicolás Alvarez 2012-05-11 19:07:15 UTC
Let's say I type this ("|" shows the text cursor):

def foo():
    a=2
    def bar():
        b=4
        c=b|

and move the cursor to the beginning of the line:

def foo():
    a=2
    def bar():
        b=4
        |c=b

If I delete one indentation level by backspacing four spaces:

def foo():
    a=2
    def bar():
        b=4
    |c=b

the code is not reparsed, and 'b' is still highlighted as a known variable, thinking the 'c' assignment is still inside the 'bar' function. Typing *anything* other than a space will trigger a reparse and make 'b' in the last line get highlighted as an unknown variable (yellow underline).

Similarly, if I have this:

def foo():
    a=2
    def bar():
        b=4
        |

code completion shows 'a' and 'b' as known local variables. But if I delete one level of indentation and complete again, it still shows 'b' (even though it's not in scope), and typing or deleting anything will trigger a reparse and make completion become correct (not showing 'b').

Very strangely, if I unindent by pressing Shift-Space instead of deleting the four spaces, the code *is* reparsed immediately, and both highlighting and completion correctly reflect the scope change.
Comment 1 Sven Brauch 2015-10-10 15:25:04 UTC
Git commit 74926cc388978e376d7ca50d9e1d15bbba6afb81 by Sven Brauch.
Committed on 10/10/2015 at 15:25.
Pushed by brauch into branch 'master'.

Fix the WhitespaceSensitivity feature for reparsing.

This never looked at removed text ...

M  +13   -11   language/backgroundparser/documentchangetracker.cpp

http://commits.kde.org/kdevplatform/74926cc388978e376d7ca50d9e1d15bbba6afb81
Comment 2 Sven Brauch 2015-10-10 15:27:06 UTC
> Very strangely, if I unindent by pressing Shift-Space
> instead of deleting the four spaces, the code *is* reparsed
> immediately, and both highlighting and completion correctly reflect the scope change.
That is because Shift+Tab removes the line, unindents it and then inserts it again. ;)