Codetools: fix TIdentifierHistoryList.Add

- If an existing item moves to the front (to HistoryIndex=0) then all Indexes between 0 and the old value need updating (the old value became unused, so items above do not need an update).
- If an new item is inserted, all existing items need to be increased.
This commit is contained in:
Martin 2023-06-28 19:30:45 +02:00
parent b326ae6b5b
commit ed410cb98c

View File

@ -4562,14 +4562,14 @@ begin
NewHistItem.Identifier:=NewItem.Identifier;
NewHistItem.NodeDesc:=NewItem.GetDesc;
NewHistItem.ParamList:=NewItem.ParamTypeList;
AdjustIndex:=0;
AdjustIndex:=high(AdjustIndex);
end;
NewHistItem.HistoryIndex:=0;
// adjust all other HistoryIndex
AnAVLNode:=Fitems.FindLowest;
while AnAVLNode<>nil do begin
AnHistItem:=TIdentHistListItem(AnAVLNode.Data);
if AnHistItem.HistoryIndex>=AdjustIndex then
if AnHistItem.HistoryIndex<AdjustIndex then
inc(AnHistItem.HistoryIndex);
AnAVLNode:=FItems.FindSuccessor(AnAVLNode);
end;