SynEdit: improve EnsureCursorPosVisible, don't force a persistent selection into view

(cherry picked from commit 093a68b134)
This commit is contained in:
Martin 2025-05-10 20:01:41 +02:00
parent 8e5d4d8638
commit 0eca1e7a08
2 changed files with 22 additions and 1 deletions

View File

@ -6860,7 +6860,11 @@ begin
MinX:=PhysCaretXY.X;
MaxX:=PhysCaretXY.X;
// sfMouseSelecting: ignore block while selecting by mouse
if SelAvail and not(sfMouseSelecting in fStateFlags) then begin
if SelAvail and not(sfMouseSelecting in fStateFlags) and
FBlockSelection.Changed and
( FCaret.IsAtLineByte(FBlockSelection.FirstLineBytePos) or
FCaret.IsAtLineByte(FBlockSelection.LastLineBytePos) )
then begin
PhysBlockBeginXY:=FBlockSelection.ViewedFirstLineCharPos;
PhysBlockEndXY :=FBlockSelection.ViewedLastLineCharPos;
if (PhysBlockBeginXY.X<>PhysBlockEndXY.X)

View File

@ -103,6 +103,7 @@ type
TSynEditSelection = class(TSynEditPointBase)
private
FChanged: Boolean;
FOnBeforeSetSelText: TSynBeforeSetSelTextList;
FAutoExtend: Boolean;
FCaret: TSynEditCaret;
@ -120,6 +121,10 @@ type
FAltStartLinePos, FAltStartBytePos: Integer; // 1 based // Alternate, for min selection
FEndLinePos: Integer; // 1 based
FEndBytePos: Integer; // 1 based
FOldStartLinePos: Integer; // 1 based
FOldStartBytePos: Integer; // 1 based
FOldEndLinePos: Integer; // 1 based
FOldEndBytePos: Integer; // 1 based
FViewedFirstStartLineCharPos: TPoint; // 1 based
FViewedLastEndLineCharPos: TPoint; // 1 based
FFLags: set of (sbViewedFirstPosValid, sbViewedLastPosValid, sbHasLineMapHandler);
@ -226,6 +231,7 @@ type
property AutoExtend: Boolean read FAutoExtend write SetAutoExtend;
property StickyAutoExtend: Boolean read FStickyAutoExtend write FStickyAutoExtend;
property Hide: Boolean read FHide write SetHide;
property Changed: Boolean read FChanged;
end;
{ TSynEditCaret }
@ -1801,12 +1807,23 @@ procedure TSynEditSelection.DoLock;
begin
inherited DoLock;
FLastCarePos := Point(-1, -1);
FOldStartLinePos := FStartLinePos;
FOldStartBytePos := FStartBytePos;
FOldEndLinePos := FEndLinePos;
FOldEndBytePos := FEndBytePos;
FChanged := False;
end;
procedure TSynEditSelection.DoUnlock;
begin
inherited DoUnlock;
FLastCarePos := Point(-1, -1);
FChanged :=
(FOldStartLinePos <> FStartLinePos) or
(FOldStartBytePos <> FStartBytePos) or
(FOldEndLinePos <> FEndLinePos) or
(FOldEndBytePos <> FEndBytePos);
end;
function TSynEditSelection.GetSelText : string;