IDE: Adjust the length of recent item lists when saving settings. Issue #33910.

git-svn-id: trunk@58469 -
This commit is contained in:
juha 2018-07-09 08:21:10 +00:00
parent 1366299857
commit 1caf3575e5
2 changed files with 26 additions and 4 deletions

View File

@ -2489,11 +2489,11 @@ begin
// recent files and directories
FXMLCfg.SetDeleteValue(Path+'Recent/OpenFiles/Max',FMaxRecentOpenFiles,DefaultMaxRecentOpenFiles);
SaveRecentList(FXMLCfg,FRecentOpenFiles,Path+'Recent/OpenFiles/');
SaveRecentList(FXMLCfg,FRecentOpenFiles,Path+'Recent/OpenFiles/',FMaxRecentOpenFiles);
FXMLCfg.SetDeleteValue(Path+'Recent/ProjectFiles/Max',FMaxRecentProjectFiles,DefaultMaxRecentProjectFiles);
SaveRecentList(FXMLCfg,FRecentProjectFiles,Path+'Recent/ProjectFiles/');
SaveRecentList(FXMLCfg,FRecentProjectFiles,Path+'Recent/ProjectFiles/',FMaxRecentProjectFiles);
FXMLCfg.SetDeleteValue(Path+'Recent/PackageFiles/Max',FMaxRecentPackageFiles,DefaultMaxRecentPackageFiles);
SaveRecentList(FXMLCfg,FRecentPackageFiles,Path+'Recent/PackageFiles/');
SaveRecentList(FXMLCfg,FRecentPackageFiles,Path+'Recent/PackageFiles/',FMaxRecentPackageFiles);
FXMLCfg.SetDeleteValue(Path+'Recent/AlreadyPopulated', FAlreadyPopulatedRecentFiles, false);

View File

@ -172,7 +172,9 @@ function CompareRecentListItem(s1, s2: string; ListType: TRecentListType): boole
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings; const Path: string;
ListType: TRecentListType);
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string);
const Path: string); overload;
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string; aMax: Integer); overload;
function AddToRecentList(const s: string; List: TStrings; aMax: integer;
ListType: TRecentListType): boolean;
function AddComboTextToRecentList(cb: TCombobox; aMax: integer;
@ -963,6 +965,26 @@ begin
SaveStringList(XMLConfig,List,Path);
end;
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string; aMax: Integer);
var
i: Integer;
s: String;
begin
if aMax>0 then
while List.Count>aMax do // Truncate list to aMax items.
List.Delete(List.Count-1);
SaveStringList(XMLConfig,List,Path);
i:=List.Count+1;
while True do
begin
s:=Path+'Item'+IntToStr(i);
if not XMLConfig.HasPath(s+'/Value',True) then Break;
XMLConfig.DeletePath(s); // Remove excess items from XML.
Inc(i);
end;
end;
function AddToRecentList(const s: string; List: TStrings; aMax: integer;
ListType: TRecentListType): boolean;
begin