Jump to start of document when setting dynamic Syntax Language

SyntaxEditor for Windows Forms Forum

Posted 6 years ago by Robert Muir
Version: 13.1.0310
Platform: Universal Windows Controls
Environment: Windows 7 (64-bit)
Avatar

I open a text file and scroll down without making any selection, then change the syntax language. The editor jumps back to the start of the document. It doesn't do this if I have made a selection. I would expect there to be no change in the position of the text in the window.

A cut down version of the code is 


DynamicSyntaxLanguage language = DynamicSyntaxLanguage.LoadFromXml(stream, 0);

syntaxEditor.Document.Language = language;

language.IsUpdating = true;

... changes to lexical states

language.IsUpdating = false;


I tried saving and restoring these, but then it jumps to the top and quicky jumps back down again. It looks pretty bad.

    syntaxEditor.SelectedView.FirstVisibleDisplayLineIndex;
    syntaxEditor.SelectedView.FirstVisibleX;

Thanks

Comments (6)

Posted 6 years ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

For your workaround you can use SuspendPainting to disable the refresh while the editor jumps. Just call SupsendPainting before you assign the language and ResumePainting after you have restored the first visible line index.


Best regards, Tobias Lingemann.

Posted 6 years ago by Robert Muir
Avatar

Thanks Tobias, that worked.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Robert,

I'm loading up our SDI Editor demo and as long as on the File menu I turn off loading example text, I can switch between languages and nothing changes in the view.  One thing that is probably more efficient in general for what you listed would be to do your IsUpdating block before you set the document language.  That will reduce the number of updates that filter up to the SyntaxEditor and might solve the problem along the way.


Actipro Software Support

Posted 6 years ago by Robert Muir
Avatar

I just tried the SDI Editor demo, and can reproduce the problem there also. After starting the editor, make sure its sufficiently small that the editor window cannot contain all the text, and scroll to the bottom of the window. Then change the language to C++.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

I think I see what's causing it now.  When we had tried, we page downed the caret to the end and it was fine when doing that.  If you scroll (without moving the caret), then that's where you see this.  It's due to a ScrollToCaret call that gets invoked as the document gets a full reparse call.  So what you are doing combined with what Tobias and I said is best to prevent the flicker and maximize performance.


Actipro Software Support

Posted 6 years ago by Robert Muir
Avatar

I've done both and its ok now, but I do think its a bug that you should fix sometime.

Thanks

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.