Skip to content

Commit

Permalink
undo: more range-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey-T committed Jun 5, 2020
1 parent e8bddfc commit 3c43e12
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions atsynedit/atstrings.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1643,11 +1643,6 @@ procedure TATStrings.DoUndoSingle(ACurList: TATUndoList;
AHardMarkedNext:= (NCount>1) and (ACurList[NCount-2].ItemHardMark);
AUnmodifiedNext:= (NCount>1) and (ACurList[NCount-2].ItemAction=aeaClearModified);

if ACurList=FUndoList then
OtherList:= FRedoList
else
OtherList:= FUndoList;

//don't undo if one item left: unmodified-mark
if ACurList.IsEmpty then exit;

Expand All @@ -1659,14 +1654,20 @@ procedure TATStrings.DoUndoSingle(ACurList: TATUndoList;
case AAction of
aeaChange:
begin
Lines[AIndex]:= AText;
LinesState[AIndex]:= ALineState;
if IsIndexValid(AIndex) then
begin
Lines[AIndex]:= AText;
LinesState[AIndex]:= ALineState;
end;
end;

aeaChangeEol:
begin
LinesEnds[AIndex]:= AEnd;
LinesState[AIndex]:= ALineState;
if IsIndexValid(AIndex) then
begin
LinesEnds[AIndex]:= AEnd;
LinesState[AIndex]:= ALineState;
end;
end;

aeaInsert:
Expand All @@ -1681,11 +1682,17 @@ procedure TATStrings.DoUndoSingle(ACurList: TATUndoList;
LineAddRaw(AText, AEnd)
else
LineInsertRaw(AIndex, AText, AEnd);
LinesState[AIndex]:= ALineState;
if IsIndexValid(AIndex) then
LinesState[AIndex]:= ALineState;
end;

aeaClearModified:
begin
if ACurList=FUndoList then
OtherList:= FRedoList
else
OtherList:= FUndoList;

OtherList.AddUnmodifiedMark;
exit;
end
Expand Down

0 comments on commit 3c43e12

Please sign in to comment.