Browse Source

Fixed InvalidOperationException when collapsing two overlapping folds.

pull/14/head
Daniel Grunwald 15 years ago
parent
commit
e12e17f6e0
  1. 14
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs

14
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs

@ -59,6 +59,20 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -59,6 +59,20 @@ namespace ICSharpCode.AvalonEdit.Folding
}
}
if (foldedUntil > offset && foldingSection != null) {
// Handle overlapping foldings: if there's another folded folding
// (starting within the foldingSection) that continues after the end of the folded section,
// then we'll extend our fold element to cover that overlapping folding.
bool foundOverlappingFolding;
do {
foundOverlappingFolding = false;
foreach (FoldingSection fs in foldingManager.GetFoldingsContaining(foldedUntil)) {
if (fs.IsFolded && fs.EndOffset > foldedUntil) {
foldedUntil = fs.EndOffset;
foundOverlappingFolding = true;
}
}
} while (foundOverlappingFolding);
string title = foldingSection.Title;
if (string.IsNullOrEmpty(title))
title = "...";

Loading…
Cancel
Save