Browse Source

Fixed SD2-1190: Exception is thrown selecting all text and then cutting/deleting it.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2063 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
c838ffb4ad
  1. 10
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/FoldMarker.cs
  2. 23
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/FoldMargin.cs

10
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/FoldMarker.cs

@ -26,11 +26,17 @@ namespace ICSharpCode.TextEditor.Document @@ -26,11 +26,17 @@ namespace ICSharpCode.TextEditor.Document
static void GetPointForOffset(IDocument document, int offset, out int line, out int column)
{
if (offset < 0) offset = 0;
if (offset >= document.TextLength) offset = document.TextLength - 1;
if (offset > document.TextLength) {
line = document.TotalNumberOfLines + 1;
column = 1;
} else if (offset < 0) {
line = -1;
column = -1;
} else {
line = document.GetLineNumberForOffset(offset);
column = offset - document.GetLineSegment(line).Offset;
}
}
public FoldType FoldType {
get { return foldType; }

23
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/FoldMargin.cs

@ -68,11 +68,13 @@ namespace ICSharpCode.TextEditor @@ -68,11 +68,13 @@ namespace ICSharpCode.TextEditor
g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), markerRectangle);
}
int currentLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y);
int currentLine = textArea.Document.GetFirstLogicalLine(textArea.TextView.FirstPhysicalLine + y);
if (currentLine < textArea.Document.TotalNumberOfLines) {
PaintFoldMarker(g, currentLine, markerRectangle);
}
}
}
}
bool SelectedFoldingFrom(List<FoldMarker> list)
{
@ -155,19 +157,22 @@ namespace ICSharpCode.TextEditor @@ -155,19 +157,22 @@ namespace ICSharpCode.TextEditor
} else {
if (isFoldEnd) {
int midy = drawingRectangle.Top + drawingRectangle.Height / 2;
// draw fold end marker
g.DrawLine(BrushRegistry.GetPen(isEndSelected ? selectedFoldLine.Color : foldLineColor.Color),
xPos,
midy,
xPos + foldMarkerSize / 2,
midy);
// draw line above fold end marker
// must be drawn after fold marker because it might have a different color than the fold marker
g.DrawLine(BrushRegistry.GetPen(isBetweenSelected || isEndSelected ? selectedFoldLine.Color : foldLineColor.Color),
xPos,
drawingRectangle.Top,
xPos,
midy);
// draw fold end marker
g.DrawLine(BrushRegistry.GetPen(isBetweenSelected || isEndSelected ? selectedFoldLine.Color : foldLineColor.Color),
xPos,
midy,
xPos + foldMarkerSize / 2,
midy);
// draw line below fold end marker
if (isBetween) {
g.DrawLine(BrushRegistry.GetPen(isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color),
@ -237,7 +242,7 @@ namespace ICSharpCode.TextEditor @@ -237,7 +242,7 @@ namespace ICSharpCode.TextEditor
}
}
#region Drawing functions
#region Drawing functions
void DrawFoldMarker(Graphics g, RectangleF rectangle, bool isOpened, bool isSelected)
{
HighlightColor foldMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor("FoldMarker");
@ -265,6 +270,6 @@ namespace ICSharpCode.TextEditor @@ -265,6 +270,6 @@ namespace ICSharpCode.TextEditor
rectangle.Y + rectangle.Height - space);
}
}
#endregion
#endregion
}
}

Loading…
Cancel
Save