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
currentContext = ImeNativeWrapper.ImmGetContext(defaultImeWnd); currentContext = ImeNativeWrapper.ImmGetContext(defaultImeWnd);
} }
previousContext = ImeNativeWrapper.ImmAssociateContext(hwndSource.Handle, currentContext); previousContext = ImeNativeWrapper.ImmAssociateContext(hwndSource.Handle, currentContext);
Debug.Assert(hwndSource != null);
Debug.Assert(currentContext != null);
hwndSource.AddHook(WndProc); hwndSource.AddHook(WndProc);
// UpdateCompositionWindow() will be called by the caret becoming visible // UpdateCompositionWindow() will be called by the caret becoming visible

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

@ -73,10 +73,19 @@ namespace ICSharpCode.AvalonEdit.Folding
/// <inheritdoc/> /// <inheritdoc/>
public override int GetFirstInterestedOffset(int startOffset) 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); return foldingManager.GetNextFoldedFoldingStart(startOffset);
else } else {
return -1; return -1;
}
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -86,7 +95,7 @@ namespace ICSharpCode.AvalonEdit.Folding
return null; return null;
int foldedUntil = -1; int foldedUntil = -1;
FoldingSection foldingSection = null; FoldingSection foldingSection = null;
foreach (FoldingSection fs in foldingManager.GetFoldingsAt(offset)) { foreach (FoldingSection fs in foldingManager.GetFoldingsContaining(offset)) {
if (fs.IsFolded) { if (fs.IsFolded) {
if (fs.EndOffset > foldedUntil) { if (fs.EndOffset > foldedUntil) {
foldedUntil = fs.EndOffset; foldedUntil = fs.EndOffset;

Loading…
Cancel
Save