mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 19:39:30 +02:00
Added try finally to some UndoBlock (editor)
git-svn-id: trunk@34977 -
This commit is contained in:
parent
c25543b689
commit
d503d615c5
@ -1593,6 +1593,7 @@ begin
|
|||||||
with TCustomSynEdit(F.CurrentEditor) do begin
|
with TCustomSynEdit(F.CurrentEditor) do begin
|
||||||
BeginUndoBlock;
|
BeginUndoBlock;
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
|
try
|
||||||
LogCaret := LogicalCaretXY;
|
LogCaret := LogicalCaretXY;
|
||||||
NewBlockBegin:=LogCaret;
|
NewBlockBegin:=LogCaret;
|
||||||
CurLine:=Lines[NewBlockBegin.Y - 1];
|
CurLine:=Lines[NewBlockBegin.Y - 1];
|
||||||
@ -1631,9 +1632,11 @@ begin
|
|||||||
else
|
else
|
||||||
if (ItemList.Count = 0) then
|
if (ItemList.Count = 0) then
|
||||||
Cancel(Sender);
|
Cancel(Sender);
|
||||||
|
finally
|
||||||
EndUpdate;
|
EndUpdate;
|
||||||
EndUndoBlock;
|
EndUndoBlock;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynCompletion.UTF8KeyPress(Sender: TObject; var Key: TUTF8Char);
|
procedure TSynCompletion.UTF8KeyPress(Sender: TObject; var Key: TUTF8Char);
|
||||||
|
@ -6192,9 +6192,12 @@ end;
|
|||||||
procedure TCustomSynEdit.ClearAll;
|
procedure TCustomSynEdit.ClearAll;
|
||||||
begin
|
begin
|
||||||
InternalBeginUndoBlock;
|
InternalBeginUndoBlock;
|
||||||
|
try
|
||||||
SelectAll;
|
SelectAll;
|
||||||
SelText:='';
|
SelText:='';
|
||||||
|
finally
|
||||||
InternalEndUndoBlock;
|
InternalEndUndoBlock;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.ClearSelection;
|
procedure TCustomSynEdit.ClearSelection;
|
||||||
|
@ -979,13 +979,16 @@ procedure TCodeContextFrm.CompleteParameters(DeclCode: string);
|
|||||||
end;
|
end;
|
||||||
// insert
|
// insert
|
||||||
ASynEdit.BeginUndoBlock;
|
ASynEdit.BeginUndoBlock;
|
||||||
|
try
|
||||||
XY:=Point(X,Y);
|
XY:=Point(X,Y);
|
||||||
ASynEdit.BlockBegin:=XY;
|
ASynEdit.BlockBegin:=XY;
|
||||||
ASynEdit.BlockEnd:=XY;
|
ASynEdit.BlockEnd:=XY;
|
||||||
ASynEdit.LogicalCaretXY:=XY;
|
ASynEdit.LogicalCaretXY:=XY;
|
||||||
ASynEdit.SelText:=NewCode;
|
ASynEdit.SelText:=NewCode;
|
||||||
|
finally
|
||||||
ASynEdit.EndUndoBlock;
|
ASynEdit.EndUndoBlock;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
SrcEdit: TSourceEditorInterface;
|
SrcEdit: TSourceEditorInterface;
|
||||||
|
@ -325,10 +325,13 @@ begin
|
|||||||
TxtXY:=CondSynEdit.LogicalCaretXY;
|
TxtXY:=CondSynEdit.LogicalCaretXY;
|
||||||
CondSynEdit.GetWordBoundsAtRowCol(TxtXY,TxtStartX,TxtEndX);
|
CondSynEdit.GetWordBoundsAtRowCol(TxtXY,TxtStartX,TxtEndX);
|
||||||
CondSynEdit.BeginUndoBlock();
|
CondSynEdit.BeginUndoBlock();
|
||||||
|
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
|
||||||
CondSynEdit.EndUndoBlock();
|
CondSynEdit.EndUndoBlock();
|
||||||
|
end;
|
||||||
FCompletionHistory.Insert(0,s);
|
FCompletionHistory.Insert(0,s);
|
||||||
if FCompletionHistory.Count>100 then
|
if FCompletionHistory.Count>100 then
|
||||||
FCompletionHistory.Delete(FCompletionHistory.Count-1);
|
FCompletionHistory.Delete(FCompletionHistory.Count-1);
|
||||||
|
@ -3404,6 +3404,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if ReadOnly then exit;
|
if ReadOnly then exit;
|
||||||
FEditor.BeginUndoBlock;
|
FEditor.BeginUndoBlock;
|
||||||
|
try
|
||||||
if not EditorComponent.SelAvail then begin
|
if not EditorComponent.SelAvail then begin
|
||||||
P.Y := FEditor.CaretY;
|
P.Y := FEditor.CaretY;
|
||||||
P.X := 1;
|
P.X := 1;
|
||||||
@ -3418,7 +3419,9 @@ begin
|
|||||||
IsPascal := EditorOpts.HighlighterList[i].DefaultCommentType <> comtCPP;
|
IsPascal := EditorOpts.HighlighterList[i].DefaultCommentType <> comtCPP;
|
||||||
// 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
|
||||||
FEditor.EndUndoBlock;
|
FEditor.EndUndoBlock;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.SortSelection;
|
procedure TSourceEditor.SortSelection;
|
||||||
@ -3443,10 +3446,13 @@ begin
|
|||||||
FEditor.BeginUpdate;
|
FEditor.BeginUpdate;
|
||||||
FEditor.BeginUndoBlock;
|
FEditor.BeginUndoBlock;
|
||||||
// ToDo: replace step by step to keep bookmarks and breakpoints
|
// ToDo: replace step by step to keep bookmarks and breakpoints
|
||||||
|
try
|
||||||
OldSelection:=EditorComponent.SelText;
|
OldSelection:=EditorComponent.SelText;
|
||||||
FEditor.SelText:=BreakLinesInText(OldSelection,FEditor.RightEdge);
|
FEditor.SelText:=BreakLinesInText(OldSelection,FEditor.RightEdge);
|
||||||
|
finally
|
||||||
FEditor.EndUndoBlock;
|
FEditor.EndUndoBlock;
|
||||||
FEditor.EndUpdate;
|
FEditor.EndUpdate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.InvertAssignment;
|
procedure TSourceEditor.InvertAssignment;
|
||||||
@ -3455,10 +3461,13 @@ begin
|
|||||||
if not EditorComponent.SelAvail then exit;
|
if not EditorComponent.SelAvail then exit;
|
||||||
FEditor.BeginUpdate;
|
FEditor.BeginUpdate;
|
||||||
FEditor.BeginUndoBlock;
|
FEditor.BeginUndoBlock;
|
||||||
|
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
|
||||||
FEditor.EndUndoBlock;
|
FEditor.EndUndoBlock;
|
||||||
FEditor.EndUpdate;
|
FEditor.EndUpdate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.SelectToBrace;
|
procedure TSourceEditor.SelectToBrace;
|
||||||
@ -3882,11 +3891,14 @@ begin
|
|||||||
if not (Line[x2] in [' ',#9]) then
|
if not (Line[x2] in [' ',#9]) then
|
||||||
s:=s+' ';
|
s:=s+' ';
|
||||||
FEditor.BeginUndoBlock;
|
FEditor.BeginUndoBlock;
|
||||||
|
try
|
||||||
FEditor.InsertTextAtCaret(s);
|
FEditor.InsertTextAtCaret(s);
|
||||||
FEditor.LogicalCaretXY:=aTextPos;
|
FEditor.LogicalCaretXY:=aTextPos;
|
||||||
|
finally
|
||||||
FEditor.EndUndoBlock;
|
FEditor.EndUndoBlock;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSourceEditor.AutoBlockCompleteChar(Char: TUTF8Char): boolean;
|
function TSourceEditor.AutoBlockCompleteChar(Char: TUTF8Char): boolean;
|
||||||
|
@ -534,11 +534,14 @@ procedure TSourceEditorInterface.ReplaceText(const StartPos, EndPos: TPoint;
|
|||||||
begin
|
begin
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
BeginUndoBlock;
|
BeginUndoBlock;
|
||||||
|
try
|
||||||
SelectText(StartPos,EndPos);
|
SelectText(StartPos,EndPos);
|
||||||
CursorTextXY:=StartPos;
|
CursorTextXY:=StartPos;
|
||||||
Selection:=NewText;
|
Selection:=NewText;
|
||||||
|
finally
|
||||||
EndUndoBlock;
|
EndUndoBlock;
|
||||||
EndUpdate;
|
EndUpdate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TIDECodeMacro }
|
{ TIDECodeMacro }
|
||||||
|
Loading…
Reference in New Issue
Block a user