How should DelimiterIndentProvider be used?

SyntaxEditor for WPF Forum

Posted 6 months ago by Bernd Timmermann - Manager, TSE GmbH
Version: 23.1.3
Platform: .NET 6.0
Environment: Windows 10 (64-bit)
Avatar

The "DelimiterIndentProvider" is documented to contain all code necessary to perform "Open/Close"-Indention with tokens.

I have overridden "IsValidStartDelimiter()" and  "IsValidEndDelimiter()" and set "base.CanAutoIndentCurlyBraces = true;" in my IndentProvider derivation constructor (should be the default anyway).

Although the overridden "GetIndentAmount()" is called in my derivation (which I give to the base implementation) the indent amout is always 0 and neither "IsValidStartDelimiter()" nor "IsValidEndDelimiter()" is called.

What did I miss?

Comments (2)

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

Hello,

I believe the IsValidStartDelimiter() and IsValidEndDelimiter methods are only called by our code when detecting if an Enter keypress is done between a start and end delimiter.  For instance, this scenario where the | character is the caret and Enter is pressed.

{|}

I'd recommend that you look at our Getting Started #12 QuickStart for a basic example of creating an indent provider for curly braces.  There is some basic logic in there that will be language specific and you'll need to tailor it to your needs.


Actipro Software Support

Posted 6 months ago by Bernd Timmermann - Manager, TSE GmbH
Avatar

Thanks for the info.

The example in #12 Quickstart uses nothing from the base class "DelimiterIndentProvider" (as far as I understand).

Some more tests showed me, that the "Opening/Closing Curly Braces" may be managed by the base class for the use by derivatives, but not for use in the base class itself. The base class is nearly without function, and you really need to implement a lot of logic with tokens to get it running.

It would have been great, if there really would be a default implementation of the standard indenting use case in the base classe.

I decided to omit this completely (Mode = None) and only use the "DocumentTextChanged" handler to implement indenting based on my parser.

This now works like a charm (after some trouble with "IndentAmount", that was solved at another thread).

The latest build of this product (v24.1.2) was released 6 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.