SynEdit, fixed clearing non persistent block, if caret moves to other end of block

git-svn-id: trunk@20979 -
This commit is contained in:
martin 2009-07-27 16:42:25 +00:00
parent df0ac93df3
commit 27a85b3e3b
2 changed files with 23 additions and 11 deletions

View File

@ -3979,7 +3979,7 @@ end;
procedure TCustomSynEdit.SetTopLine(Value: Integer);
var
Delta: Integer;
OldTopView: LongInt;
OldTopView: Integer;
begin
if fPaintLock > 0 then begin
// defer scrolling, to minimize any possible flicker
@ -5481,16 +5481,20 @@ begin
ecLeft, ecSelLeft, ecColSelLeft:
begin
if (eoCaretSkipsSelection in Options2) and (Command=ecLeft)
and SelAvail and FCaret.IsAtLineByte(FBlockSelection.LastLineBytePos) then
FCaret.LineBytePos := FBlockSelection.FirstLineBytePos
and SelAvail and FCaret.IsAtLineByte(FBlockSelection.LastLineBytePos) then begin
FBlockSelection.IgnoreNextCaretMove;
FCaret.LineBytePos := FBlockSelection.FirstLineBytePos;
end
else
MoveCaretHorz(-1);
end;
ecRight, ecSelRight, ecColSelRight:
begin
if (eoCaretSkipsSelection in Options2) and (Command=ecRight)
and SelAvail and FCaret.IsAtLineByte(FBlockSelection.FirstLineBytePos) then
FCaret.LineBytePos := FBlockSelection.LastLineBytePos
and SelAvail and FCaret.IsAtLineByte(FBlockSelection.FirstLineBytePos) then begin
FBlockSelection.IgnoreNextCaretMove;
FCaret.LineBytePos := FBlockSelection.LastLineBytePos;
end
else
MoveCaretHorz(1);
end;

View File

@ -88,6 +88,7 @@ type
FEndBytePos: Integer; // 1 based
FPersistent: Boolean;
FPersistentLock: Integer;
FIgnoreNextCaretMove: Boolean;
(* On any modification, remember the position of the caret.
If it gets moved from there to either end of the block, this should be ignored
This happens, if Block and caret are adjusted directly
@ -124,6 +125,7 @@ type
function SelCanContinue(ACaret: TSynEditCaret): Boolean;
function IsBackwardSel: Boolean; // SelStart < SelEnd ?
procedure SortSelectionPoints;
procedure IgnoreNextCaretMove;
procedure IncPersistentLock;
procedure DecPersistentLock;
procedure Clear;
@ -734,7 +736,14 @@ begin
end;
procedure TSynEditSelection.DoCaretChanged(Sender: TObject);
var
Ignore: Boolean;
begin
Ignore := FIgnoreNextCaretMove;
FIgnoreNextCaretMove := False;
if Ignore then
exit;
if (FCaret.IsAtLineByte(StartLineBytePos) or
FCaret.IsAtLineByte(EndLineBytePos)) and
FCaret.WasAtLineChar(FLastCarePos)
@ -757,15 +766,9 @@ begin
exit;
end;
if FPersistent or (FPersistentLock > 0) then
exit;
if FCaret.IsAtLineByte(StartLineBytePos) or
FCaret.IsAtLineByte(EndLineBytePos)
then
exit;
StartLineBytePos := FCaret.LineBytePos;
end;
@ -1315,6 +1318,11 @@ begin
end;
end;
procedure TSynEditSelection.IgnoreNextCaretMove;
begin
FIgnoreNextCaretMove := True;
end;
procedure TSynEditSelection.IncPersistentLock;
begin
inc(FPersistentLock)