Collapsed #region

SyntaxEditor for WPF Forum

Posted 7 years ago by Horst Noll
Version: 17.2.0661


how can display a text instead of "..." when I collapse a region?

For example...

#region BlockA

shall look like when its collapsed


 and not "..."

Thanks in advance.


Comments (2)

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

Our .NET Languages Add-on does region text like this in a custom OutliningNodeDefinition:

public override object GetCollapsedContent(IOutliningNode node) {
	if (node != null) {
		// Get the node's snapshot range
		TextSnapshotRange snapshotRange = node.SnapshotRange;
		// Get the end offset of the start line
		int lineEndOffset = snapshotRange.StartLine.EndOffset;

		// Get the start line's text
		string text = snapshotRange.Snapshot.GetSubstring(new TextRange(snapshotRange.StartOffset, Math.Min(snapshotRange.EndOffset, lineEndOffset)));

		// If the text starts with '#region'...
		if (text.StartsWith("#region", StringComparison.OrdinalIgnoreCase)) {
			// If there is any non-whitespace text remaining, use that
			text = text.Substring("#region".Length).Trim();
			if (!string.IsNullOrEmpty(text))
				return text;

	// Fallback to default
	return base.GetCollapsedContent(node);

Actipro Software Support

Posted 7 years ago by Horst Noll

This worked like a charm.

Thanks a lot.

The latest build of this product (v24.1.2) 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.