mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-05 15:58:15 +02:00
IDE: save/restore Find/Replace dialog state if dialog was canceled. Issue #31567, modified patch by FTurtle
git-svn-id: trunk@54454 -
This commit is contained in:
parent
20a9ecf1d5
commit
f3a6a4e47b
@ -43,6 +43,12 @@ type
|
||||
TOnFindDlgKey = procedure(Sender: TObject; var Key: Word; Shift:TShiftState;
|
||||
FindDlgComponent: TFindDlgComponent) of Object;
|
||||
|
||||
TLazFindReplaceState = record
|
||||
FindText: string;
|
||||
ReplaceText: string;
|
||||
Options: TSynSearchOptions;
|
||||
end;
|
||||
|
||||
{ TLazFindReplaceDialog }
|
||||
|
||||
TLazFindReplaceDialog = class(TForm)
|
||||
@ -102,6 +108,8 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure UpdateHints;
|
||||
procedure ResetUserHistory;
|
||||
procedure RestoreState(const AState: TLazFindReplaceState);
|
||||
procedure SaveState(out AState: TLazFindReplaceState);
|
||||
public
|
||||
property Options: TSynSearchOptions read GetOptions write SetOptions;
|
||||
property EnableAutoComplete: boolean read GetEnableAutoComplete
|
||||
@ -212,8 +220,24 @@ begin
|
||||
DlgHistoryIndex[c] := -1;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.TextToFindComboBoxKeyDown(
|
||||
Sender: TObject; var Key:Word; Shift:TShiftState);
|
||||
procedure TLazFindReplaceDialog.RestoreState(const AState: TLazFindReplaceState
|
||||
);
|
||||
begin
|
||||
Options:=AState.Options;
|
||||
FindText:=AState.FindText;
|
||||
ReplaceText:=AState.ReplaceText;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.SaveState(out AState: TLazFindReplaceState);
|
||||
begin
|
||||
FillChar(AState, SizeOf(TLazFindReplaceState), 0);
|
||||
AState.Options:=Options;
|
||||
AState.FindText:=FindText;
|
||||
AState.ReplaceText:=ReplaceText;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.TextToFindComboboxKeyDown(Sender: TObject;
|
||||
var Key: Word; Shift: TShiftState);
|
||||
var
|
||||
Component: TFindDlgComponent;
|
||||
HistoryList: TStringList;
|
||||
|
@ -3332,7 +3332,9 @@ var
|
||||
NewOptions: TSynSearchOptions;
|
||||
ALeft,ATop:integer;
|
||||
DlgResult: TModalResult;
|
||||
AState: TLazFindReplaceState;
|
||||
begin
|
||||
LazFindReplaceDialog.SaveState(AState);
|
||||
LazFindReplaceDialog.ResetUserHistory;
|
||||
//debugln('TSourceEditor.StartFindAndReplace A LazFindReplaceDialog.FindText="',dbgstr(LazFindReplaceDialog.FindText),'"');
|
||||
if ReadOnly then Replace := False;
|
||||
@ -3384,7 +3386,10 @@ begin
|
||||
InputHistoriesSO.FindOptions:=LazFindReplaceDialog.Options*SaveOptions;
|
||||
InputHistoriesSO.FindAutoComplete:=LazFindReplaceDialog.EnableAutoComplete;
|
||||
if DlgResult = mrCancel then
|
||||
begin
|
||||
LazFindReplaceDialog.RestoreState(AState);
|
||||
exit;
|
||||
end;
|
||||
//debugln('TSourceEditor.StartFindAndReplace B LazFindReplaceDialog.FindText="',dbgstr(LazFindReplaceDialog.FindText),'"');
|
||||
|
||||
Replace:=ssoReplace in LazFindReplaceDialog.Options;
|
||||
|
Loading…
Reference in New Issue
Block a user