Incorrect Outlining Nodes when the 2 Outlining Ranges span across each other

SyntaxEditor for WPF Forum

Posted 3 years ago by Erwin Liong
Version: 16.1.0634
Platform: .NET 4.5
Environment: Windows 10 (64-bit)
Avatar

Hi Actipro,

 

I added 2 outlining nodes whose range overlaps each other. The outcome of the collapsible range is incorrect.

Here are the steps to reproduce:

  1. Navigate to [dir]\v16.1.0634\SampleBrowser\ProductSamples\SyntaxEditorSamples\QuickStart\CodeOutliningRangeBased\JavascriptOutliningSource.cs
  2. Change the Outlining Source to manually add 2 nodes:
  3. var firstRange = new TextRange(snapshot.PositionToOffset(new TextPosition(0, 0)),
    	snapshot.PositionToOffset(new TextPosition(10, 0)));
    var secondRange = new TextRange(snapshot.PositionToOffset(new TextPosition(5, 0)),
    	snapshot.PositionToOffset(new TextPosition(20, 0)));
    
    this.AddNode(firstRange, multiLineCommentDefinition);
    this.AddNode(secondRange, curlyBraceDefinition);
  4. Observe that the first node is from line 1-11 (still correct) but the second node is from line 6-11 (instead of line 6-21).

In Visual Studio, similar overlapping range can be achieved with the following code block; where the first range is for the #region-endregion pair and the other range is for the class Foo's brackets.

#region

class Foo
{
    #endregion    
}

 Would you be able to fix this, please?

Thank you.

 

Regards,

Erwin Liong

Comments (3)

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

Hello,

Sorry but our core outlining engine doesn't support overlapping nodes like that.  It only supports nested nodes.  Adding overlapping node support is unfortunately not an easy change, as it would require completely rearchitecting how we track and update all outlining node data.


Actipro Software Support

Posted 3 years ago by Erwin Liong
Avatar

Hi Actipro,

 

In that case, is there a workaround?

I am thinking of not adding a node if the range of the node to be added overlaps with one of the node in the outlining manager. But, during the AddOutliningNode in RangeOutliningSourceBase, I am not able to get any child nodes from the Outlining manager because they are not added yet.

 

Is there a proper way of retrieving all the information for the nodes added? If there isn't , is there a way for me to do post processing and remove the overlapping node from the outlining manager?

 

Thank you.

[Modified 3 years ago]

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

Hello,

RangeOutliningSourceBase doesn't store pairs of offsets together unfortunately.  Internally it's a flat list of offsets at which a start/end occurs and the kind of node definition (and action) at that offset.  Thus we don't even track a hierarchy at that level.  That occurs later on in the automatic outlining phase, where a tree structure is built.  We don't have a way for you to remove anything later on though.

You would need to probably write your own mechanism to use for building up node data (or just inherit our RangeOutliningSourceBase and override its Add* methods).  Then cache all the node data and try to detect this scenario on your own and modify your cached data as necessary.  When you reach the end of the document and have scrubbed the data, then use your cached data to call our base Add* methods.  That's the only thing I can think of for this.  Either that or detect at a higher level (i.e. the code that calls the Add* methods in general) when this situation occurs and avoid it there.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.