LazEdit: when dealing with SelStart and SelEnd,.use Length (not Utf8Length) because SynEdit internally works with bytpositions.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3829 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
lazarus-bart
2014-12-06 23:34:38 +00:00
parent 739e0a8f41
commit 753ec5dfa0

View File

@ -725,18 +725,15 @@ var
SLen: Integer;
OldSelMode: TSynSelectionMode;
begin
{
//This method makes no sense when we are in Colomn selection mode
if SelAvail and (SelectionMode = smColumn) then Exit;
}
//this only works with SelectionMode := scNormal
OldSelMode := SelectionMode;
SelectionMode := smNormal;
//Using SelEnd - SelStart doesn't work correctly when selecting across lines
SLen := Utf8Length(Seltext); //SelStart - SelEnd;
//SynEdit internally works with byte positions, therefore use Length(), not Utf8Length()
SLen := {Utf8}Length(Seltext); //SelStart - SelEnd;
SelText := Pre + SelText + Post;
//SelStart now is after Post, place it before the original selection
SelStart := SelStart - Utf8Length(Post) - SLen;
SelStart := SelStart - {Utf8}Length(Post) - SLen;
SelEnd := SelStart + SLen;
SelectionMode := OldSelMode;
SetFocus;