fix, search widget, limited the max length of a search/replacement to prevent an issue that could occurred during CE init

This commit is contained in:
Basile Burg 2015-11-12 04:48:42 +01:00
parent 66b77b5a05
commit d15527338f
2 changed files with 34 additions and 18 deletions

View File

@ -24,7 +24,8 @@ inherited CESearchWidget: TCESearchWidget
Align = alTop Align = alTop
AutoSize = False AutoSize = False
BorderSpacing.Around = 4 BorderSpacing.Around = 4
ItemHeight = 15 ItemHeight = 0
MaxLength = 128
OnChange = cbToFindChange OnChange = cbToFindChange
TabOrder = 0 TabOrder = 0
end end
@ -128,14 +129,14 @@ inherited CESearchWidget: TCESearchWidget
Align = alClient Align = alClient
BorderSpacing.Around = 4 BorderSpacing.Around = 4
Caption = 'Options' Caption = 'Options'
ClientHeight = 77 ClientHeight = 67
ClientWidth = 382 ClientWidth = 382
TabOrder = 4 TabOrder = 4
object chkWWord: TCheckBox object chkWWord: TCheckBox
Left = 8 Left = 8
Height = 23 Height = 26
Top = 0 Top = 0
Width = 86 Width = 97
Caption = 'whole word' Caption = 'whole word'
Checked = True Checked = True
State = cbChecked State = cbChecked
@ -143,17 +144,17 @@ inherited CESearchWidget: TCESearchWidget
end end
object chkBack: TCheckBox object chkBack: TCheckBox
Left = 8 Left = 8
Height = 23 Height = 26
Top = 24 Top = 24
Width = 75 Width = 87
Caption = 'backward' Caption = 'backward'
TabOrder = 1 TabOrder = 1
end end
object chkFromCur: TCheckBox object chkFromCur: TCheckBox
Left = 8 Left = 8
Height = 23 Height = 26
Top = 48 Top = 48
Width = 86 Width = 98
Caption = 'from cursor' Caption = 'from cursor'
Checked = True Checked = True
State = cbChecked State = cbChecked
@ -161,25 +162,25 @@ inherited CESearchWidget: TCESearchWidget
end end
object chkCaseSens: TCheckBox object chkCaseSens: TCheckBox
Left = 128 Left = 128
Height = 23 Height = 26
Top = 0 Top = 0
Width = 95 Width = 111
Caption = 'case sensitive' Caption = 'case sensitive'
TabOrder = 3 TabOrder = 3
end end
object chkPrompt: TCheckBox object chkPrompt: TCheckBox
Left = 128 Left = 128
Height = 23 Height = 26
Top = 24 Top = 24
Width = 64 Width = 73
Caption = 'prompt' Caption = 'prompt'
TabOrder = 4 TabOrder = 4
end end
object chkRegex: TCheckBox object chkRegex: TCheckBox
Left = 128 Left = 128
Height = 23 Height = 26
Top = 48 Top = 48
Width = 119 Width = 139
Caption = 'regular expression' Caption = 'regular expression'
Checked = True Checked = True
State = cbChecked State = cbChecked
@ -244,13 +245,14 @@ inherited CESearchWidget: TCESearchWidget
ClientWidth = 386 ClientWidth = 386
TabOrder = 5 TabOrder = 5
object cbReplaceWth: TComboBox object cbReplaceWth: TComboBox
Left = 94 Left = 108
Height = 23 Height = 23
Top = 0 Top = 0
Width = 292 Width = 278
Align = alClient Align = alClient
Anchors = [akTop, akLeft, akBottom] Anchors = [akTop, akLeft, akBottom]
ItemHeight = 15 ItemHeight = 0
MaxLength = 128
OnChange = cbReplaceWthChange OnChange = cbReplaceWthChange
TabOrder = 1 TabOrder = 1
end end
@ -258,7 +260,7 @@ inherited CESearchWidget: TCESearchWidget
Left = 0 Left = 0
Height = 23 Height = 23
Top = 0 Top = 0
Width = 94 Width = 108
Align = alLeft Align = alLeft
Caption = 'Replace with ' Caption = 'Replace with '
OnChange = chkEnableRepChange OnChange = chkEnableRepChange

View File

@ -35,6 +35,7 @@ type
property recentSearches: TStringList read fMrSearches write setMrSearches; property recentSearches: TStringList read fMrSearches write setMrSearches;
property recentReplacements: TStringList read fMrReplacements write setMrReplacements; property recentReplacements: TStringList read fMrReplacements write setMrReplacements;
public public
procedure afterLoad; override;
constructor create(aOwner: TComponent); override; constructor create(aOwner: TComponent); override;
destructor destroy; override; destructor destroy; override;
procedure Assign(aValue: TPersistent); override; procedure Assign(aValue: TPersistent); override;
@ -160,6 +161,19 @@ procedure TCESearchOptions.setMrReplacements(aValue: TStringList);
begin begin
fMrReplacements.Assign(aValue); fMrReplacements.Assign(aValue);
end; end;
procedure TCESearchOptions.afterLoad;
var
i: integer;
begin
inherited;
for i := fMrReplacements.Count-1 downto 0 do
if length(fMrReplacements[i]) > 128 then
fMrReplacements.Delete(i);
for i := fMrSearches.Count-1 downto 0 do
if length(fMrSearches[i]) > 128 then
fMrSearches.Delete(i);
end;
{$ENDREGION} {$ENDREGION}
{$REGION Standard Comp/Obj------------------------------------------------------} {$REGION Standard Comp/Obj------------------------------------------------------}