improved TUnitInfo.ReadUnitNameFromSource

git-svn-id: trunk@7810 -
This commit is contained in:
mattias 2005-09-23 21:40:32 +00:00
parent 58e2d96223
commit 95e49adf77
2 changed files with 12 additions and 8 deletions

View File

@ -5495,6 +5495,7 @@ begin
if Result<>mrOk then exit;
if Handled then exit;
end;
debugln('TMainIDE.DoOpenEditorFile ',NewUnitInfo.Filename,' ',NewUnitInfo.UnitName);
// check readonly
NewUnitInfo.FileReadOnly:=FileExists(NewUnitInfo.Filename)

View File

@ -719,19 +719,22 @@ procedure TUnitInfo.ReadUnitNameFromSource(TryCache: boolean);
var
NewUnitName: String;
begin
if TryCache then begin
NewUnitName:='';
if TryCache then
NewUnitName:=CodeToolBoss.GetCachedSourceName(Source);
if NewUnitName<>'' then begin
fUnitName:=NewUnitName;
if NewUnitName='' then
NewUnitName:=CodeToolBoss.GetSourceName(fSource,false);
if NewUnitName='' then begin
// unable to parse the source
// use default: the filename
NewUnitName:=ExtractFileNameOnly(Filename);
if CompareText(NewUnitName,fUnitName)=0 then begin
// the last stored unitname has the better case
exit;
end;
end;
NewUnitName:=CodeToolBoss.GetSourceName(fSource,false);
if (NewUnitName='') then begin
NewUnitName:=ExtractFileNameOnly(Filename);
if CompareText(NewUnitName,fUnitName)=0 then exit;
if NewUnitName<>'' then
fUnitName:=NewUnitName;
end;
end;
function TUnitInfo.CreateUnitName: string;