SynEdit: Fixed a rare issue with wrongly placed caret after overwriting the selection.

git-svn-id: trunk@40678 -
This commit is contained in:
martin 2013-04-01 11:47:15 +00:00
parent 4c539b83a7
commit 0493e2f195

View File

@ -222,6 +222,7 @@ type
public
constructor Create;
procedure AssignFrom(Src: TSynEditBaseCaret);
procedure Invalidate; // force to 1,1
function IsAtLineChar(aPoint: TPoint): Boolean;
function IsAtLineByte(aPoint: TPoint; aByteOffset: Integer = -1): Boolean;
@ -560,6 +561,14 @@ begin
SetLines(Src.FLines);
end;
procedure TSynEditBaseCaret.Invalidate;
begin
FLinePos := 1;
FCharPos := 1;
FBytePos := 1;
FFlags := [];
end;
function TSynEditBaseCaret.IsAtLineChar(aPoint: TPoint): Boolean;
begin
ValidateCharPos;
@ -1349,6 +1358,7 @@ begin
// Calculate the byte positions for each line
SetLength(Col, Last - First + 1);
SetLength(Len, Last - First + 1);
FInternalCaret.Invalidate;
FInternalCaret.LineBytePos := FirstLineBytePos;
C1 := FInternalCaret.CharPos;
FInternalCaret.LineBytePos := LastLineBytePos;
@ -1768,6 +1778,7 @@ begin
// BB is lower than BE
BB := FirstLineBytePos;
BE := LastLineBytePos;
FInternalCaret.Invalidate;
if SelAvail then begin
if FActiveSelectionMode = smLine then begin
BB.X := 1;