Skip to content

Commit 6d5e2b6

Browse files
author
Storm
committed
2 parents b447590 + 7995fac commit 6d5e2b6

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

FastColoredTextBox/FastColoredTextBox.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5067,6 +5067,13 @@ protected override void OnPaint(PaintEventArgs e)
50675067
for (int iWordWrapLine = 0; iWordWrapLine < lineInfo.WordWrapStringsCount; iWordWrapLine++)
50685068
{
50695069
y = lineInfo.startY + iWordWrapLine*CharHeight - VerticalScroll.Value;
5070+
// break if too long line (important for extremly big lines)
5071+
if (y > VerticalScroll.Value + ClientSize.Height)
5072+
break;
5073+
// continue if wordWrapLine isn't seen yet (important for extremly big lines)
5074+
if (lineInfo.startY + iWordWrapLine * CharHeight < VerticalScroll.Value)
5075+
continue;
5076+
50705077
//indent
50715078
var indent = iWordWrapLine == 0 ? 0 : lineInfo.wordWrapIndent * CharWidth;
50725079
//draw chars
@@ -5836,7 +5843,7 @@ private void SelectWord(Place p)
58365843
Selection = new Range(this, toX, p.iLine, fromX, p.iLine);
58375844
}
58385845

5839-
private int YtoLineIndex(int y)
5846+
public int YtoLineIndex(int y)
58405847
{
58415848
int i = LineInfos.BinarySearch(new LineInfo(-10), new LineYComparer(y));
58425849
i = i < 0 ? -i - 2 : i;
@@ -5875,6 +5882,15 @@ public Place PointToPlace(Point point)
58755882
iLine = FindPrevVisibleLine(iLine);
58765883
//
58775884
int iWordWrapLine = LineInfos[iLine].WordWrapStringsCount;
5885+
5886+
//set iWordWrapLine more accurate (important for extremly big lines)
5887+
if (y > point.Y)
5888+
{
5889+
int approximatelyLines = (y - point.Y - CharHeight) / CharHeight;
5890+
y -= approximatelyLines * CharHeight;
5891+
iWordWrapLine -= approximatelyLines;
5892+
}
5893+
58785894
do
58795895
{
58805896
iWordWrapLine--;

0 commit comments

Comments
 (0)