To make it clear, why the current code does not work:
needReparse is set to true whenever text is inserted or deleted, but the reparsing is only triggered if we leave the current line.
This does normally (never ?) happen inside the same event, so we have to remember whether a reparse is needed, either with a member-variable or a static local variable.