Skip to content

Commit b72eb8a

Browse files
committed
rewrite fuzzy search, #5509
1 parent 37c14bc commit b72eb8a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

app/proc_str.pas

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@ function SFindFuzzyPositions(const SText, SFind: UnicodeString): TATIntArray;
111111
end;
112112
//
113113
var
114-
STextUpper: UnicodeString;
114+
STextUpper, SFindUpper: UnicodeString;
115115
i, N, N2: integer;
116116
begin
117117
Result:= nil;
118118
STextUpper:= UnicodeUpperCase(SText);
119+
SFindUpper:= UnicodeUpperCase(SFind);
119120

120121
//if simple match is found, don't calculate complex fuzzy matches
121-
N:= Pos(UnicodeUpperCase(SFind), UnicodeUpperCase(SText));
122+
N:= Pos(SFindUpper, STextUpper);
122123
if N>0 then
123124
begin
124125
SetLength(Result, Length(SFind));
@@ -129,13 +130,13 @@ function SFindFuzzyPositions(const SText, SFind: UnicodeString): TATIntArray;
129130
end;
130131

131132
//calculate complex matches
132-
SetLength(Result, Length(SFind));
133+
SetLength(Result, Length(SFindUpper));
133134
N2:= 0;
134-
for i:= 1 to Length(SFind) do
135+
for i:= 1 to Length(SFindUpper) do
135136
begin
136137
N:= N2;
137138
repeat
138-
N2:= PosEx(UpCase(SFind[i]), STextUpper, N2+1);
139+
N2:= PosEx(SFindUpper[i], STextUpper, N2+1);
139140
if N2=0 then Exit(nil);
140141

141142
if N2=N+1 then Break;

0 commit comments

Comments
 (0)