Browse Source

Fix "InvalidOperationException: Trying to build visual line from collapsed line" when the start of a folding section is hidden by a different element generator than the FoldingElementGenerator. (e.g. TruncateLongLines)

pull/39/merge
Daniel Grunwald 13 years ago
parent
commit
9ff68ecaed
  1. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs
  2. 15
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs

@ -107,8 +107,6 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -107,8 +107,6 @@ namespace ICSharpCode.AvalonEdit.Editing
currentContext = ImeNativeWrapper.ImmGetContext(defaultImeWnd);
}
previousContext = ImeNativeWrapper.ImmAssociateContext(hwndSource.Handle, currentContext);
Debug.Assert(hwndSource != null);
Debug.Assert(currentContext != null);
hwndSource.AddHook(WndProc);
// UpdateCompositionWindow() will be called by the caret becoming visible

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

@ -73,11 +73,20 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -73,11 +73,20 @@ namespace ICSharpCode.AvalonEdit.Folding
/// <inheritdoc/>
public override int GetFirstInterestedOffset(int startOffset)
{
if (foldingManager != null)
if (foldingManager != null) {
foreach (FoldingSection fs in foldingManager.GetFoldingsContaining(startOffset)) {
// Test whether we're currently within a folded folding (that didn't just end).
// If so, create the fold marker immediately.
// This is necessary if the actual beginning of the fold marker got skipped due to another VisualElementGenerator.
if (fs.IsFolded && fs.EndOffset > startOffset) {
//return startOffset;
}
}
return foldingManager.GetNextFoldedFoldingStart(startOffset);
else
} else {
return -1;
}
}
/// <inheritdoc/>
public override VisualLineElement ConstructElement(int offset)
@ -86,7 +95,7 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -86,7 +95,7 @@ namespace ICSharpCode.AvalonEdit.Folding
return null;
int foldedUntil = -1;
FoldingSection foldingSection = null;
foreach (FoldingSection fs in foldingManager.GetFoldingsAt(offset)) {
foreach (FoldingSection fs in foldingManager.GetFoldingsContaining(offset)) {
if (fs.IsFolded) {
if (fs.EndOffset > foldedUntil) {
foldedUntil = fs.EndOffset;

Loading…
Cancel
Save