From a747d43139f77b9af98f803aa9e95b0399a553b0 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 24 Jul 2023 12:05:21 +0200 Subject: [PATCH] Codetools: IdentifierCompletion, with "include identifier containing prefix" sort recent entries with true prefix before such "only containing" (same as for non recent items) --- components/codetools/identcompletiontool.pas | 46 ++++++++++++-------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index 878652cc52..ce8fecf8a5 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -699,25 +699,37 @@ var procedure AddHistoryCurItem(ForceComp: Boolean); var CurItmComp: TIdentifierCompatibility; - j: integer; + j, f: integer; + MatchAtStart, HasContainMatch: Boolean; begin - for j := 0 to length(FFoundHistoryItems) - 1 do begin - CurItem := FFoundHistoryItems[j]; - if (CurItem = nil) then - continue; - if ForceComp then - CurItmComp := low(TIdentifierCompatibility) - else - CurItmComp := CurItem.Compatibility; - if (CurItmComp <> HistComp) then - Continue; - if (CurItem.HistoryIndex > HistoryLimits[CurItmComp]) then - break; - if (CurItem.Identifier<>'') and (FilterCurItem >= 0) then begin - CurItem.Flags := CurItem.Flags + [iliIsRecentItem]; - InsertCurItem; + HasContainMatch := False; + repeat + MatchAtStart := not HasContainMatch; + for j := 0 to length(FFoundHistoryItems) - 1 do begin + CurItem := FFoundHistoryItems[j]; + if (CurItem = nil) then + continue; + if ForceComp then + CurItmComp := low(TIdentifierCompatibility) + else + CurItmComp := CurItem.Compatibility; + if (CurItmComp <> HistComp) then + Continue; + if (CurItem.HistoryIndex > HistoryLimits[CurItmComp]) then + break; + if (CurItem.Identifier<>'') then begin + f := FilterCurItem; + if f > 0 then + HasContainMatch := True; + if ( (f = 0) and MatchAtStart) or + ( (f > 0) and not MatchAtStart) + then begin + CurItem.Flags := CurItem.Flags + [iliIsRecentItem]; + InsertCurItem; + end; + end; end; - end; + until (not HasContainMatch) or (not MatchAtStart) end; begin