Browse Source

Skip folds that only span a single line

pull/2276/head
Siegfried Pammer 5 years ago
parent
commit
c4930a81b5
  1. 9
      ILSpy/TextView/AvalonEditTextOutput.cs

9
ILSpy/TextView/AvalonEditTextOutput.cs

@ -99,7 +99,7 @@ namespace ICSharpCode.ILSpy.TextView
TextSegmentCollection<ReferenceSegment> references = new TextSegmentCollection<ReferenceSegment>(); TextSegmentCollection<ReferenceSegment> references = new TextSegmentCollection<ReferenceSegment>();
/// <summary>Stack of the fold markers that are open but not closed yet</summary> /// <summary>Stack of the fold markers that are open but not closed yet</summary>
Stack<NewFolding> openFoldings = new Stack<NewFolding>(); Stack<(NewFolding, int startLine)> openFoldings = new Stack<(NewFolding, int startLine)>();
/// <summary>List of all foldings that were written to the output</summary> /// <summary>List of all foldings that were written to the output</summary>
internal readonly List<NewFolding> Foldings = new List<NewFolding>(); internal readonly List<NewFolding> Foldings = new List<NewFolding>();
@ -315,18 +315,19 @@ namespace ICSharpCode.ILSpy.TextView
public void MarkFoldStart(string collapsedText = "...", bool defaultCollapsed = false) public void MarkFoldStart(string collapsedText = "...", bool defaultCollapsed = false)
{ {
WriteIndent(); WriteIndent();
openFoldings.Push( openFoldings.Push((
new NewFolding { new NewFolding {
StartOffset = this.TextLength, StartOffset = this.TextLength,
Name = collapsedText, Name = collapsedText,
DefaultClosed = defaultCollapsed DefaultClosed = defaultCollapsed
}); }, lineNumber));
} }
public void MarkFoldEnd() public void MarkFoldEnd()
{ {
NewFolding f = openFoldings.Pop(); var (f, startLine) = openFoldings.Pop();
f.EndOffset = this.TextLength; f.EndOffset = this.TextLength;
if (startLine != lineNumber)
this.Foldings.Add(f); this.Foldings.Add(f);
} }

Loading…
Cancel
Save