SynEdit: fix DragOver, don't reset caret to pos=1 if dragging over gutter or decoration, related to issue #40177

This commit is contained in:
Martin 2023-03-24 23:13:16 +01:00
parent 2a06079ae9
commit bc2d68125a

View File

@ -6336,23 +6336,32 @@ begin
inherited;
LastMouseCaret:=Point(-1,-1);
if (eoAcceptDragDropEditing in FOptions2) and (Source is TCustomSynEdit) then begin
Accept := False;
if (not ReadOnly) and TCustomSynEdit(Source).SelAvail then
begin
FBlockSelection.IncPersistentLock;
try
//if State = dsDragLeave then //restore prev caret position
// ComputeCaret(FMouseDownX, FMouseDownY)
//else //position caret under the mouse cursor
ComputeCaret(X, Y);
Accept := (X >= FTextArea.Bounds.Left) and
(X < FTextArea.Bounds.Right) and
(Y >= FTextArea.Bounds.Top) and
(Y < FTextArea.Bounds.Bottom);
if Accept and (not ReadOnly) and TCustomSynEdit(Source).SelAvail then
begin
//if State = dsDragLeave then //restore prev caret position
// ComputeCaret(FMouseDownX, FMouseDownY)
//else //position caret under the mouse cursor
FInternalCaret.AssignFrom(FCaret);
FInternalCaret.LineCharPos := PixelsToRowColumn(Point(X,Y));
Accept := CheckDragDropAccecpt(FInternalCaret.LineBytePos, Source, DropMove);
if Accept then begin
FBlockSelection.IncPersistentLock;
try
FCaret.LineCharPos := FInternalCaret.LineCharPos;
finally
FBlockSelection.DecPersistentLock;
end;
Accept := CheckDragDropAccecpt(LogicalCaretXY, Source, DropMove);
if DropMove then
DragCursor := crDrag
else
DragCursor := crMultiDrag;
finally
FBlockSelection.DecPersistentLock;
end;
end;
end;