SynEdi: more debugln for undo

git-svn-id: trunk@35067 -
This commit is contained in:
martin 2012-01-31 19:26:25 +00:00
parent 3330db0aba
commit f88a9d1f56
13 changed files with 81 additions and 55 deletions

View File

@ -1353,7 +1353,7 @@ begin
exit; exit;
end; end;
CurSrcEdit.BeginUndoBlock; CurSrcEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCodyIdentifiersDlg.UseIdentifier'){$ENDIF};
try try
// insert or replace identifier // insert or replace identifier
if (not CurSrcEdit.SelectionAvailable) if (not CurSrcEdit.SelectionAvailable)
@ -1380,7 +1380,7 @@ begin
if not SameUnitName then if not SameUnitName then
AddToUsesSection; AddToUsesSection;
finally finally
CurSrcEdit.EndUndoBlock; CurSrcEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCodyIdentifiersDlg.UseIdentifier'){$ENDIF};
end; end;
end; end;

View File

@ -292,7 +292,7 @@ begin
debugln(['InsertCallInherited CodeToolBoss.SourceChangeCache.Replace failed']); debugln(['InsertCallInherited CodeToolBoss.SourceChangeCache.Replace failed']);
exit; exit;
end; end;
SrcEdit.BeginUndoBlock; SrcEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('InsertCallInherited'){$ENDIF};
try try
SrcEdit.CursorTextXY:=NewXY; SrcEdit.CursorTextXY:=NewXY;
if not CodeToolBoss.SourceChangeCache.Apply then begin if not CodeToolBoss.SourceChangeCache.Apply then begin
@ -300,7 +300,7 @@ begin
exit; exit;
end; end;
finally finally
SrcEdit.EndUndoBlock; SrcEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('InsertCallInherited'){$ENDIF};
end; end;
except except
on e: Exception do CodeToolBoss.HandleException(e); on e: Exception do CodeToolBoss.HandleException(e);

View File

@ -1591,7 +1591,7 @@ begin
// Note: Form.Visible can be false, for example when completion only contains one item // Note: Form.Visible can be false, for example when completion only contains one item
if F.CurrentEditor is TCustomSynEdit then if F.CurrentEditor is TCustomSynEdit then
with TCustomSynEdit(F.CurrentEditor) do begin with TCustomSynEdit(F.CurrentEditor) do begin
BeginUndoBlock; BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSynCompletion.Validate'){$ENDIF};
BeginUpdate; BeginUpdate;
try try
LogCaret := LogicalCaretXY; LogCaret := LogicalCaretXY;
@ -1634,7 +1634,7 @@ begin
Cancel(Sender); Cancel(Sender);
finally finally
EndUpdate; EndUpdate;
EndUndoBlock; EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSynCompletion.Validate'){$ENDIF};
end; end;
end; end;
end; end;

View File

@ -792,9 +792,9 @@ type
destructor Destroy; override; destructor Destroy; override;
procedure AfterLoadFromFile; procedure AfterLoadFromFile;
procedure BeginUndoBlock; procedure BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF};
procedure BeginUpdate(WithUndoBlock: Boolean = True); procedure BeginUpdate(WithUndoBlock: Boolean = True);
procedure EndUndoBlock; procedure EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF};
procedure EndUpdate; procedure EndUpdate;
public public
@ -2097,7 +2097,7 @@ begin
if (FUndoBlockAtPaintLock > FPaintLock) then if (FUndoBlockAtPaintLock > FPaintLock) then
debugln(['***** SYNEDIT: Fixing auto-undo-block FUndoBlockAtPaintLock=',FUndoBlockAtPaintLock,' FPaintLock=',FPaintLock]); debugln(['***** SYNEDIT: Fixing auto-undo-block FUndoBlockAtPaintLock=',FUndoBlockAtPaintLock,' FPaintLock=',FPaintLock]);
FUndoBlockAtPaintLock := 0; FUndoBlockAtPaintLock := 0;
EndUndoBlock; EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCustomSynEdit.DoDecPaintLock'){$ENDIF};
end; end;
if (FPaintLock=1) and HandleAllocated then begin if (FPaintLock=1) and HandleAllocated then begin
ScanRanges(FLastTextChangeStamp <> TSynEditStringList(FLines).TextChangeStamp); ScanRanges(FLastTextChangeStamp <> TSynEditStringList(FLines).TextChangeStamp);
@ -3298,6 +3298,9 @@ begin
If FPaintLock > 0 then begin If FPaintLock > 0 then begin
debugln(['Warning: SynEdit.Paint called during PaintLock']); debugln(['Warning: SynEdit.Paint called during PaintLock']);
{$IFDEF SynCheckPaintLock}
DumpStack;
{$ENDIF}
// Ensure this will be repainted after PaintLock // Ensure this will be repainted after PaintLock
if FInvalidateRect.Top < 0 then if FInvalidateRect.Top < 0 then
FInvalidateRect := rcClip FInvalidateRect := rcClip
@ -5621,6 +5624,12 @@ begin
end; end;
finally finally
InternalEndUndoBlock; InternalEndUndoBlock;
{$IFDEF SynCheckPaintLock}
if (FPaintLock > 0) and (FInvalidateRect.Bottom > FInvalidateRect.Top) then begin
debugln(['TCustomSynEdit.CommandProcessor: Paint called while locked InitialCmd=', InitialCmd, ' Command=', Command]);
DumpStack;
end;
{$ENDIF}
end; end;
end; end;
end; end;
@ -6245,6 +6254,9 @@ end;
procedure TCustomSynEdit.InternalBeginUndoBlock(aList: TSynEditUndoList); procedure TCustomSynEdit.InternalBeginUndoBlock(aList: TSynEditUndoList);
begin begin
if aList = nil then aList := fUndoList; if aList = nil then aList := fUndoList;
{$IFDEF SynUndoDebugBeginEnd}
DebugLnEnter(['>> TCustomSynEdit.InternalBeginUndoBlock', DbgSName(self), ' ', dbgs(Self), ' aList=', aList, ' FPaintLock=', FPaintLock, ' InGroupCount=',aList.InGroupCount]);
{$ENDIF}
aList.OnNeedCaretUndo := {$IFDEF FPC}@{$ENDIF}GetCaretUndo; aList.OnNeedCaretUndo := {$IFDEF FPC}@{$ENDIF}GetCaretUndo;
aList.BeginBlock; aList.BeginBlock;
IncPaintLock; IncPaintLock;
@ -6261,10 +6273,17 @@ begin
// after unfold // after unfold
DecPaintLock; DecPaintLock;
aList.EndBlock; // Todo: Doing this after DecPaintLock, can cause duplicate calls to StatusChanged(scModified) aList.EndBlock; // Todo: Doing this after DecPaintLock, can cause duplicate calls to StatusChanged(scModified)
{$IFDEF SynUndoDebugBeginEnd}
DebugLnEnter(['<< TCustomSynEdit.InternalEndUndoBlock', DbgSName(self), ' ', dbgs(Self), ' aList=', aList, ' FPaintLock=', FPaintLock, ' InGroupCount=',aList.InGroupCount]);
{$ENDIF}
end; end;
procedure TCustomSynEdit.BeginUndoBlock; procedure TCustomSynEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF};
begin begin
{$IFDEF SynUndoDebugBeginEnd}
DebugLnEnter(['>> TCustomSynEdit.BeginUndoBlock ', DbgSName(self), ' ', dbgs(Self), ' Caller=', ACaller, ' FPaintLock=', FPaintLock, ' InGroupCount=',fUndoList.InGroupCount]);
if ACaller = '' then DumpStack;
{$ENDIF}
fUndoList.OnNeedCaretUndo := {$IFDEF FPC}@{$ENDIF}GetCaretUndo; fUndoList.OnNeedCaretUndo := {$IFDEF FPC}@{$ENDIF}GetCaretUndo;
fUndoList.BeginBlock; fUndoList.BeginBlock;
////FFoldedLinesView.Lock; ////FFoldedLinesView.Lock;
@ -6276,17 +6295,21 @@ begin
IncPaintLock; IncPaintLock;
if WithUndoBlock and (FUndoBlockAtPaintLock = 0) then begin if WithUndoBlock and (FUndoBlockAtPaintLock = 0) then begin
FUndoBlockAtPaintLock := FPaintLock; FUndoBlockAtPaintLock := FPaintLock;
BeginUndoBlock; BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('SynEdit.BeginUpdate'){$ENDIF};
end; end;
end; end;
procedure TCustomSynEdit.EndUndoBlock; procedure TCustomSynEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF};
begin begin
// Write all trimming info to the end of the undo block, // Write all trimming info to the end of the undo block,
// so it will be undone first, and other UndoItems do see the expected spaces // so it will be undone first, and other UndoItems do see the expected spaces
//FTrimmedLinesView.UnLock; //FTrimmedLinesView.UnLock;
////FFoldedLinesView.UnLock; ////FFoldedLinesView.UnLock;
fUndoList.EndBlock; fUndoList.EndBlock;
{$IFDEF SynUndoDebugBeginEnd}
DebugLnEnter(['<< TCustomSynEdit.EndUndoBlock', DbgSName(self), ' ', dbgs(Self), ' Caller=', ACaller, ' FPaintLock=', FPaintLock, ' InGroupCount=',fUndoList.InGroupCount]);
//if ACaller = '' then DumpStack;
{$ENDIF}
end; end;
procedure TCustomSynEdit.EndUpdate; procedure TCustomSynEdit.EndUpdate;

View File

@ -208,6 +208,9 @@ type
function RealCount: Integer; function RealCount: Integer;
function IsTopMarkedAsUnmodified: boolean; function IsTopMarkedAsUnmodified: boolean;
function UnModifiedMarkerExists: boolean; function UnModifiedMarkerExists: boolean;
{$IFDEF SynUndoDebugBeginEnd}
property InGroupCount: integer read FInGroupCount;
{$ENDIF}
public public
property CanUndo: boolean read GetCanUndo; property CanUndo: boolean read GetCanUndo;
property FullUndoImpossible: boolean read fFullUndoImposible; property FullUndoImpossible: boolean read fFullUndoImposible;
@ -372,7 +375,7 @@ begin
FForceGroupEnd := False; FForceGroupEnd := False;
end; end;
{$IFDEF SynUndoDebugCalls} {$IFDEF SynUndoDebugCalls}
DebugLnExit(['>> TSynEditUndoList.EndBlock ', DebugName, ' ', DbgSName(self), ' ', dbgs(Self), ' fLockCount=', fLockCount, ' Cnt=', fItems.Count, ' FInGroupCount=', FInGroupCount, ' fUnModifiedItem=', fUnModifiedItem]); DebugLnExit(['<< TSynEditUndoList.EndBlock ', DebugName, ' ', DbgSName(self), ' ', dbgs(Self), ' fLockCount=', fLockCount, ' Cnt=', fItems.Count, ' FInGroupCount=', FInGroupCount, ' fUnModifiedItem=', fUnModifiedItem]);
end else begin end else begin
DebugLn(['** EXTRA TSynEditUndoList.EndBlock ', DebugName, ' ', DbgSName(self), ' ', dbgs(Self), ' fLockCount=', fLockCount, ' Cnt=', fItems.Count, ' FInGroupCount=', FInGroupCount, ' fUnModifiedItem=', fUnModifiedItem]); DebugLn(['** EXTRA TSynEditUndoList.EndBlock ', DebugName, ' ', DbgSName(self), ' ', dbgs(Self), ' fLockCount=', fLockCount, ' Cnt=', fItems.Count, ' FInGroupCount=', FInGroupCount, ' fUnModifiedItem=', fUnModifiedItem]);
{$ENDIF} {$ENDIF}

View File

@ -169,7 +169,7 @@ procedure TTestSynEdit.TestSetSelText(Value: String; PasteMode: TSynSelectionMod
AFlags: TTestSetSelFlags); AFlags: TTestSetSelFlags);
begin begin
if not(tssSkipUndoBlock in AFlags) then if not(tssSkipUndoBlock in AFlags) then
BeginUndoBlock; BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('test'){$ENDIF};
if (tssUpdateBlock in AFlags) then if (tssUpdateBlock in AFlags) then
BeginUpdate(False); BeginUpdate(False);
@ -180,7 +180,7 @@ begin
if (tssUpdateBlock in AFlags) then if (tssUpdateBlock in AFlags) then
EndUpdate; EndUpdate;
if not(tssSkipUndoBlock in AFlags) then if not(tssSkipUndoBlock in AFlags) then
EndUndoBlock; EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('test'){$ENDIF};
end; end;
procedure TTestSynEdit.SimulatePaintText; procedure TTestSynEdit.SimulatePaintText;

View File

@ -1071,11 +1071,11 @@ procedure TTestSynSelection.ReplaceSelText;
SetLines(TheText); SetLines(TheText);
SetCaretAndSel(X1,Y1, X2,Y2); SetCaretAndSel(X1,Y1, X2,Y2);
TestIsBlock ('Sanity, selection at begin of test (3)', X1,Y1, X2,Y2, Before); TestIsBlock ('Sanity, selection at begin of test (3)', X1,Y1, X2,Y2, Before);
SynEdit.BeginUndoBlock; SynEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('test sel'){$ENDIF};
SynEdit.BeginUpdate(False); SynEdit.BeginUpdate(False);
SynEdit.SelText := ''; SynEdit.SelText := '';
SynEdit.TestSetSelText(LinesToText(Replace), SelInsertMode); SynEdit.TestSetSelText(LinesToText(Replace), SelInsertMode);
SynEdit.EndUndoBlock; SynEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('test sel'){$ENDIF};
SynEdit.EndUpdate; SynEdit.EndUpdate;
TestIsCaretPhys('After Replace (2 step, locked)', ExpCaretX, ExpCaretY); TestIsCaretPhys('After Replace (2 step, locked)', ExpCaretX, ExpCaretY);
TestIsNoBlock ('After Replace (2 step, locked)'); TestIsNoBlock ('After Replace (2 step, locked)');

View File

@ -534,14 +534,14 @@ var UpdateMode: TUpdateMode;
procedure BeginUndoBlock; procedure BeginUndoBlock;
begin begin
if UpdateMode = umOuter then SynEdit.BeginUpdate; if UpdateMode = umOuter then SynEdit.BeginUpdate;
SynEdit.BeginUndoBlock; SynEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('test'){$ENDIF};
if UpdateMode = umInner then SynEdit.BeginUpdate; if UpdateMode = umInner then SynEdit.BeginUpdate;
end; end;
procedure EndUndoBlock; procedure EndUndoBlock;
begin begin
if UpdateMode = umInner then SynEdit.EndUpdate; if UpdateMode = umInner then SynEdit.EndUpdate;
SynEdit.EndUndoBlock; SynEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('test'){$ENDIF};
if UpdateMode = umOuter then SynEdit.EndUpdate; if UpdateMode = umOuter then SynEdit.EndUpdate;
end; end;
@ -554,10 +554,10 @@ var UpdateMode: TUpdateMode;
SetCaret(1,1); SetCaret(1,1);
// need to add space later, so it is regocnized as trailing // need to add space later, so it is regocnized as trailing
BeginUndoBlock; BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('test'){$ENDIF};
SynEdit.TextBetweenPointsEx[point(5,1), point(6,1), scamEnd] := ''; // delete d SynEdit.TextBetweenPointsEx[point(5,1), point(6,1), scamEnd] := ''; // delete d
SynEdit.TextBetweenPointsEx[point(4,2), point(4,2), scamEnd] := ' '; // add space SynEdit.TextBetweenPointsEx[point(4,2), point(4,2), scamEnd] := ' '; // add space
EndUndoBlock; EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('test'){$ENDIF};
TestIsFullText ('modified after block', ['abc', 'mno ', 'xyz', '']); TestIsFullText ('modified after block', ['abc', 'mno ', 'xyz', '']);
TestIsCaret('modified after block', 5,2); TestIsCaret('modified after block', 5,2);

View File

@ -978,7 +978,7 @@ procedure TCodeContextFrm.CompleteParameters(DeclCode: string);
exit; exit;
end; end;
// insert // insert
ASynEdit.BeginUndoBlock; ASynEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCodeContextFrm.CompleteParameters'){$ENDIF};
try try
XY:=Point(X,Y); XY:=Point(X,Y);
ASynEdit.BlockBegin:=XY; ASynEdit.BlockBegin:=XY;
@ -986,7 +986,7 @@ procedure TCodeContextFrm.CompleteParameters(DeclCode: string);
ASynEdit.LogicalCaretXY:=XY; ASynEdit.LogicalCaretXY:=XY;
ASynEdit.SelText:=NewCode; ASynEdit.SelText:=NewCode;
finally finally
ASynEdit.EndUndoBlock; ASynEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCodeContextFrm.CompleteParameters'){$ENDIF};
end; end;
end; end;

View File

@ -324,13 +324,13 @@ begin
if p>0 then s:=copy(s,1,p-1); if p>0 then s:=copy(s,1,p-1);
TxtXY:=CondSynEdit.LogicalCaretXY; TxtXY:=CondSynEdit.LogicalCaretXY;
CondSynEdit.GetWordBoundsAtRowCol(TxtXY,TxtStartX,TxtEndX); CondSynEdit.GetWordBoundsAtRowCol(TxtXY,TxtStartX,TxtEndX);
CondSynEdit.BeginUndoBlock(); CondSynEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCompOptBuildMacrosFrame.fSynCompletionValidate'){$ENDIF};
try try
CondSynEdit.BlockBegin:=Point(TxtStartX,TxtXY.Y); CondSynEdit.BlockBegin:=Point(TxtStartX,TxtXY.Y);
CondSynEdit.BlockEnd:=Point(TxtEndX,TxtXY.Y); CondSynEdit.BlockEnd:=Point(TxtEndX,TxtXY.Y);
CondSynEdit.SelText:=s; CondSynEdit.SelText:=s;
finally finally
CondSynEdit.EndUndoBlock(); CondSynEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCompOptBuildMacrosFrame.fSynCompletionValidate'){$ENDIF};
end; end;
FCompletionHistory.Insert(0,s); FCompletionHistory.Insert(0,s);
if FCompletionHistory.Count>100 then if FCompletionHistory.Count>100 then

View File

@ -346,8 +346,8 @@ type
function Close: Boolean; function Close: Boolean;
// codebuffer // codebuffer
procedure BeginUndoBlock; override; procedure BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF}; override;
procedure EndUndoBlock; override; procedure EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF}; override;
procedure BeginUpdate; override; procedure BeginUpdate; override;
procedure EndUpdate; override; procedure EndUpdate; override;
procedure BeginGlobalUpdate; procedure BeginGlobalUpdate;
@ -2211,7 +2211,7 @@ begin
try try
CodeToolsInSync:=not NeedsUpdateCodeBuffer; CodeToolsInSync:=not NeedsUpdateCodeBuffer;
if SrcLogEntry<>nil then begin if SrcLogEntry<>nil then begin
SynEditor.BeginUndoBlock; SynEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditorSharedValues.OnCodeBufferChanged'){$ENDIF};
SynEditor.BeginUpdate; SynEditor.BeginUpdate;
SynEditor.TemplateEdit.IncExternalEditLock; SynEditor.TemplateEdit.IncExternalEditLock;
SynEditor.SyncroEdit.IncExternalEditLock; SynEditor.SyncroEdit.IncExternalEditLock;
@ -2246,7 +2246,7 @@ begin
SynEditor.SyncroEdit.DecExternalEditLock; SynEditor.SyncroEdit.DecExternalEditLock;
SynEditor.TemplateEdit.DecExternalEditLock; SynEditor.TemplateEdit.DecExternalEditLock;
SynEditor.EndUpdate; SynEditor.EndUpdate;
SynEditor.EndUndoBlock; SynEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditorSharedValues.OnCodeBufferChanged'){$ENDIF};
end; end;
end else begin end else begin
{$IFDEF VerboseSrcEditBufClean} {$IFDEF VerboseSrcEditBufClean}
@ -2282,14 +2282,14 @@ begin
inc(FInGlobalUpdate); inc(FInGlobalUpdate);
if FInGlobalUpdate > 1 then exit; if FInGlobalUpdate > 1 then exit;
SynEditor.BeginUpdate; // locks all shared SynEdits too SynEditor.BeginUpdate; // locks all shared SynEdits too
SynEditor.BeginUndoBlock; SynEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditorSharedValues.BeginGlobalUpdate'){$ENDIF};
end; end;
procedure TSourceEditorSharedValues.EndGlobalUpdate; procedure TSourceEditorSharedValues.EndGlobalUpdate;
begin begin
dec(FInGlobalUpdate); dec(FInGlobalUpdate);
if FInGlobalUpdate > 0 then exit; if FInGlobalUpdate > 0 then exit;
SynEditor.EndUndoBlock; SynEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditorSharedValues.EndGlobalUpdate'){$ENDIF};
SynEditor.EndUpdate; SynEditor.EndUpdate;
end; end;
@ -3363,7 +3363,7 @@ begin
end; end;
BeginUpdate; BeginUpdate;
BeginUndoBlock; BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.UpdateCommentSelection'){$ENDIF};
FEditor.SelectionMode := smNormal; FEditor.SelectionMode := smNormal;
if CommentOn then begin if CommentOn then begin
@ -3391,7 +3391,7 @@ begin
end; end;
end; end;
EndUndoBlock; EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.UpdateCommentSelection'){$ENDIF};
EndUpdate; EndUpdate;
FEditor.CaretXY := OldCaretPos; FEditor.CaretXY := OldCaretPos;
@ -3407,7 +3407,7 @@ var
P: TPoint; P: TPoint;
begin begin
if ReadOnly then exit; if ReadOnly then exit;
FEditor.BeginUndoBlock; FEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.ConditionalSelection'){$ENDIF};
try try
if not EditorComponent.SelAvail then begin if not EditorComponent.SelAvail then begin
P.Y := FEditor.CaretY; P.Y := FEditor.CaretY;
@ -3424,7 +3424,7 @@ begin
// will show modal dialog - must not be in Editor.BeginUpdate block, or painting will not work // will show modal dialog - must not be in Editor.BeginUpdate block, or painting will not work
FEditor.SelText:=AddConditional(EditorComponent.SelText,IsPascal); FEditor.SelText:=AddConditional(EditorComponent.SelText,IsPascal);
finally finally
FEditor.EndUndoBlock; FEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.ConditionalSelection'){$ENDIF};
end; end;
end; end;
@ -3448,13 +3448,13 @@ begin
if ReadOnly then exit; if ReadOnly then exit;
if not EditorComponent.SelAvail then exit; if not EditorComponent.SelAvail then exit;
FEditor.BeginUpdate; FEditor.BeginUpdate;
FEditor.BeginUndoBlock; FEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.BreakLinesInSelection'){$ENDIF};
// ToDo: replace step by step to keep bookmarks and breakpoints // ToDo: replace step by step to keep bookmarks and breakpoints
try try
OldSelection:=EditorComponent.SelText; OldSelection:=EditorComponent.SelText;
FEditor.SelText:=BreakLinesInText(OldSelection,FEditor.RightEdge); FEditor.SelText:=BreakLinesInText(OldSelection,FEditor.RightEdge);
finally finally
FEditor.EndUndoBlock; FEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.BreakLinesInSelection'){$ENDIF};
FEditor.EndUpdate; FEditor.EndUpdate;
end; end;
end; end;
@ -3464,12 +3464,12 @@ begin
if ReadOnly then exit; if ReadOnly then exit;
if not EditorComponent.SelAvail then exit; if not EditorComponent.SelAvail then exit;
FEditor.BeginUpdate; FEditor.BeginUpdate;
FEditor.BeginUndoBlock; FEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.InvertAssignment'){$ENDIF};
try try
// ToDo: replace step by step to keep bookmarks and breakpoints // ToDo: replace step by step to keep bookmarks and breakpoints
FEditor.SelText := InvertAssignTool.InvertAssignment(FEditor.SelText); FEditor.SelText := InvertAssignTool.InvertAssignment(FEditor.SelText);
finally finally
FEditor.EndUndoBlock; FEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.InvertAssignment'){$ENDIF};
FEditor.EndUpdate; FEditor.EndUpdate;
end; end;
end; end;
@ -3894,12 +3894,12 @@ begin
s:=' '+CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.BeautifyKeyWord(s); s:=' '+CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.BeautifyKeyWord(s);
if not (Line[x2] in [' ',#9]) then if not (Line[x2] in [' ',#9]) then
s:=s+' '; s:=s+' ';
FEditor.BeginUndoBlock; FEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.AutoBlockCompleteChar'){$ENDIF};
try try
FEditor.InsertTextAtCaret(s); FEditor.InsertTextAtCaret(s);
FEditor.LogicalCaretXY:=aTextPos; FEditor.LogicalCaretXY:=aTextPos;
finally finally
FEditor.EndUndoBlock; FEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.AutoBlockCompleteChar'){$ENDIF};
end; end;
end; end;
end; end;
@ -3926,13 +3926,13 @@ begin
debugln(['TSourceEditor.AutoBlockCompleteChar ']); debugln(['TSourceEditor.AutoBlockCompleteChar ']);
// user typed 'begin' // user typed 'begin'
if not LazarusIDE.SaveSourceEditorChangesToCodeCache(self) then exit; if not LazarusIDE.SaveSourceEditorChangesToCodeCache(self) then exit;
FEditor.BeginUndoBlock; FEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.AutoBlockCompleteChar (2)'){$ENDIF};
FEditor.BeginUpdate; FEditor.BeginUpdate;
try try
if not CodeToolBoss.CompleteBlock(CodeBuffer,p.X,p.Y,true) then exit; if not CodeToolBoss.CompleteBlock(CodeBuffer,p.X,p.Y,true) then exit;
finally finally
FEditor.EndUpdate; FEditor.EndUpdate;
FEditor.EndUndoBlock; FEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.AutoBlockCompleteChar (2)'){$ENDIF};
end; end;
end; end;
end; end;
@ -3945,7 +3945,7 @@ var
begin begin
if not LazarusIDE.SaveSourceEditorChangesToCodeCache(self) then exit; if not LazarusIDE.SaveSourceEditorChangesToCodeCache(self) then exit;
XY:=FEditor.LogicalCaretXY; XY:=FEditor.LogicalCaretXY;
FEditor.BeginUndoBlock; FEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.AutoCompleteBlock'){$ENDIF};
FEditor.BeginUpdate; FEditor.BeginUpdate;
try try
if not CodeToolBoss.CompleteBlock(CodeBuffer,XY.X,XY.Y,false, if not CodeToolBoss.CompleteBlock(CodeBuffer,XY.X,XY.Y,false,
@ -3960,7 +3960,7 @@ begin
end; end;
finally finally
FEditor.EndUpdate; FEditor.EndUpdate;
FEditor.EndUndoBlock; FEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.AutoCompleteBlock'){$ENDIF};
end; end;
end; end;
@ -4283,14 +4283,14 @@ Begin
CodeBuffer := nil; CodeBuffer := nil;
end; end;
procedure TSourceEditor.BeginUndoBlock; procedure TSourceEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF};
begin begin
FEditor.BeginUndoBlock; FEditor.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.BeginUndoBlock ' + ACaller){$ENDIF};
end; end;
procedure TSourceEditor.EndUndoBlock; procedure TSourceEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF};
begin begin
FEditor.EndUndoBlock; FEditor.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditor.EndUndoBlock ' + ACaller){$ENDIF};
end; end;
procedure TSourceEditor.BeginUpdate; procedure TSourceEditor.BeginUpdate;

View File

@ -114,7 +114,7 @@ begin
else else
RemoveUnits:=nil; RemoveUnits:=nil;
if (RemoveUnits<>nil) and (RemoveUnits.Count>0) then begin if (RemoveUnits<>nil) and (RemoveUnits.Count>0) then begin
SrcEdit.BeginUndoBlock; SrcEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('ShowUnusedUnitsDialog'){$ENDIF};
try try
for i:=0 to RemoveUnits.Count-1 do begin for i:=0 to RemoveUnits.Count-1 do begin
if not CodeToolBoss.RemoveUnitFromAllUsesSections(Code,RemoveUnits[i]) if not CodeToolBoss.RemoveUnitFromAllUsesSections(Code,RemoveUnits[i])
@ -124,7 +124,7 @@ begin
end; end;
end; end;
finally finally
SrcEdit.EndUndoBlock; SrcEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('ShowUnusedUnitsDialog'){$ENDIF};
end; end;
end; end;
finally finally

View File

@ -140,8 +140,8 @@ type
// DesktopXY:=EditorControl.ClientToScreen(ScreenToPixelPosition(ScreenXY)); // DesktopXY:=EditorControl.ClientToScreen(ScreenToPixelPosition(ScreenXY));
// update // update
procedure BeginUndoBlock; virtual; abstract; procedure BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF}; virtual; abstract;
procedure EndUndoBlock; virtual; abstract; procedure EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}(ACaller: String = ''){$ENDIF}; virtual; abstract;
procedure BeginUpdate; virtual; abstract; // block painting procedure BeginUpdate; virtual; abstract; // block painting
procedure EndUpdate; virtual; abstract; procedure EndUpdate; virtual; abstract;
procedure IncreaseIgnoreCodeBufferLock; virtual; abstract; procedure IncreaseIgnoreCodeBufferLock; virtual; abstract;
@ -533,13 +533,13 @@ procedure TSourceEditorInterface.ReplaceText(const StartPos, EndPos: TPoint;
const NewText: string); const NewText: string);
begin begin
BeginUpdate; BeginUpdate;
BeginUndoBlock; BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditorInterface.ReplaceText'){$ENDIF};
try try
SelectText(StartPos,EndPos); SelectText(StartPos,EndPos);
CursorTextXY:=StartPos; CursorTextXY:=StartPos;
Selection:=NewText; Selection:=NewText;
finally finally
EndUndoBlock; EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSourceEditorInterface.ReplaceText'){$ENDIF};
EndUpdate; EndUpdate;
end; end;
end; end;