SynEdit: small refactor (don't hold copy of undolist in syncro plugin)

git-svn-id: trunk@35954 -
This commit is contained in:
martin 2012-03-13 23:43:51 +00:00
parent 149c8660b0
commit 43a5ae2dff

View File

@ -244,8 +244,6 @@ type
private private
FLastCell: Integer; FLastCell: Integer;
FUndoRealCount, FRedoRealCount: Integer; FUndoRealCount, FRedoRealCount: Integer;
FRedoList: TSynEditUndoList;
FUndoList: TSynEditUndoList;
FExternalEditLock: Integer; FExternalEditLock: Integer;
protected protected
procedure SetUndoStart; // Handle undo/redo stuff procedure SetUndoStart; // Handle undo/redo stuff
@ -1106,9 +1104,9 @@ end;
procedure TSynPluginCustomSyncroEdit.SetUndoStart; procedure TSynPluginCustomSyncroEdit.SetUndoStart;
begin begin
FUndoList.ForceGroupEnd; ViewedTextBuffer.UndoList.ForceGroupEnd;
FUndoRealCount := FUndoList.RealCount; FUndoRealCount := ViewedTextBuffer.UndoList.RealCount;
FRedoRealCount := FRedoList.RealCount; FRedoRealCount := ViewedTextBuffer.RedoList.RealCount;
end; end;
procedure TSynPluginCustomSyncroEdit.SetEditor(const AValue: TCustomSynEdit); procedure TSynPluginCustomSyncroEdit.SetEditor(const AValue: TCustomSynEdit);
@ -1116,14 +1114,10 @@ begin
if Editor = AValue then exit; if Editor = AValue then exit;
if Editor <> nil then begin if Editor <> nil then begin
CaretObj.RemoveChangeHandler(@DoCaretChanged); CaretObj.RemoveChangeHandler(@DoCaretChanged);
FRedoList := nil;
FUndoList := nil;
end; end;
inherited SetEditor(AValue); inherited SetEditor(AValue);
if Editor <> nil then begin if Editor <> nil then begin
CaretObj.AddChangeHandler(@DoCaretChanged); CaretObj.AddChangeHandler(@DoCaretChanged);
FRedoList := ViewedTextBuffer.RedoList;
FUndoList := ViewedTextBuffer.UndoList;
end; end;
end; end;
@ -1165,10 +1159,10 @@ var
c1, c2: Integer; c1, c2: Integer;
begin begin
inherited; inherited;
if IsUndoing and (FUndoRealCount >= 0) and (FUndoList.RealCount < FUndoRealCount) if IsUndoing and (FUndoRealCount >= 0) and (ViewedTextBuffer.UndoList.RealCount < FUndoRealCount)
then then
Active := false; Active := false;
if IsRedoing and (FRedoRealCount >= 0) and (FRedoList.RealCount < FUndoRealCount) if IsRedoing and (FRedoRealCount >= 0) and (ViewedTextBuffer.RedoList.RealCount < FUndoRealCount)
then then
Active := false; Active := false;
if aUndoRedo or not Active then exit; if aUndoRedo or not Active then exit;