
Thanks. I understand your concept, but if I have a parser at hand, that knows about the structure, it should do the work.
Therefore I let it compute all indents in the "CreateParseData"-Override (still in Parser-Thread).
Currently I have the Indent mode set to "None" and go with the OnDocumentTextChanged() event alone.
While continously typing, the update works fine, and only for the last change I either need to type an additional blank or start some explizit reindenting funktion.
This works astonishingly good with one exception: The cursor jumps around on changes not done sequentially.
If I have a block and put an "If" before, and an "Endif" beyond, the cursor ("Caret") jumps back several lines after entering the "E" of the "EndIf" at the end of the block. That's when there is enough data to reindent the block.
I assume that's caused by the inserted spaces in the text and/or the asynchronous nature of "ITextSnapshotLine.IndentAmount".
Restoring the cursor position by resetting the "editor.ActiveView.Selection.CaretPosition" to the value saved on entry into "OnDocumentTextChanged()" doesn't help (the DisplayLine of the saved position is still correct, as lines didn't change).
Any idea how I could stop my solution from jumping around?
Besides: When I change indents that way, I get a lot of induced OnDocumentTextChanged() calls.
I currently get rid of this by a pause in my indent logic created by time locker at the beginning of the "OnDocumentTextChanged()" method (after calling the base method).
(Another question: Should I put such problems in a new thread, or is it OK to continue the current one?)
Thank in advance.