IDE: find in files: fixed endless loop in padding filenames

git-svn-id: trunk@14425 -
This commit is contained in:
mattias 2008-03-05 12:12:13 +00:00
parent fc8080d388
commit 8d42e3ebab

View File

@ -706,8 +706,10 @@ begin
fMatches:= 0; fMatches:= 0;
if Assigned(fResultsList) then if Assigned(fResultsList) then
begin begin
fResultsList.BeginUpdate; if not fResultsListUpdating then begin
fResultsListUpdating:=true; fResultsList.BeginUpdate;
fResultsListUpdating:=true;
end;
try try
if fSearchFiles then if fSearchFiles then
begin begin
@ -845,12 +847,17 @@ end;
procedure TSearchForm.UpdateProgress(FileName: string); procedure TSearchForm.UpdateProgress(FileName: string);
var var
DisplayFileName: string; DisplayFileName: string;
ShorterFileName: String;
begin begin
DisplayFileName := FileName; DisplayFileName := FileName;
//DebugLn(['TSearchForm.UpdateProgress DisplayFileName="',dbgstr(DisplayFileName),'"']);
lblProgress.Caption:= DisplayFileName; lblProgress.Caption:= DisplayFileName;
while (lblProgress.Left + lblProgress.Width)> lblProgress.Parent.ClientWidth-12 do while (lblProgress.Left + lblProgress.Width)> lblProgress.Parent.ClientWidth-12 do
begin begin
DisplayFileName:= PadAndShorten(DisplayFileName); ShorterFileName:= PadAndShorten(DisplayFileName);
if ShorterFileName=DisplayFileName then break;
DisplayFileName:=ShorterFileName;
//DebugLn(['TSearchForm.UpdateProgress Padded DisplayFileName="',dbgstr(DisplayFileName),'"']);
lblProgress.Caption := DisplayFileName; lblProgress.Caption := DisplayFileName;
end;//while end;//while
end;//UpdateProgress end;//UpdateProgress
@ -881,11 +888,12 @@ function TSearchForm.PadAndShorten(FileName: string): string;
var var
FoundAt: integer; FoundAt: integer;
begin begin
result:= ''; FoundAt:= System.Pos(PathDelim,FileName);
FoundAt:= pos(PathDelim,FileName); if FoundAt<1 then begin
inc(FoundAt); Result := Filename;
result:= copy(FileName,FoundAt,Length(FileName)); end else begin
result:= fPad + result; Result:= fPad + copy(FileName,FoundAt+1,Length(FileName));
end;
end;//PadAndShorten end;//PadAndShorten
initialization initialization