IDE: save new package unit: set initialdir to package dir

git-svn-id: trunk@35600 -
This commit is contained in:
mattias 2012-02-26 17:44:27 +00:00
parent e82a9ebdb8
commit f441b83baf
3 changed files with 14 additions and 17 deletions

View File

@ -717,7 +717,7 @@ type
procedure ShortenFilename(var ExpandedFilename: string; UseUp: boolean);
procedure LongenFilename(var AFilename: string);
function FindPkgFile(const AFilename: string;
IgnoreRemoved, FindNewFile: boolean): TPkgFile;
IgnoreRemoved, FindVirtualFile: boolean): TPkgFile;
function FindUnitWithRegister(IgnorePkgFile: TPkgFile = nil): TPkgFile;
function FindUnit(const TheUnitName: string): TPkgFile;
function FindUnit(const TheUnitName: string; IgnoreRemoved: boolean): TPkgFile;
@ -3086,8 +3086,8 @@ begin
Result:=FComponents.IndexOf(PkgComponent);
end;
function TLazPackage.FindPkgFile(const AFilename: string;
IgnoreRemoved, FindNewFile: boolean): TPkgFile;
function TLazPackage.FindPkgFile(const AFilename: string; IgnoreRemoved,
FindVirtualFile: boolean): TPkgFile;
var
TheFilename: String;
Cnt: Integer;
@ -3097,20 +3097,11 @@ begin
TheFilename:=AFilename;
if FindNewFile and (not FilenameIsAbsolute(TheFilename)) then begin
// this is a virtual file, not yet saved
// -> prepend Package Directory and check if it does not exists yet in
// the package directory
LongenFilename(TheFilename);
if FileExistsUTF8(TheFilename) then begin
// the file exists -> this virtual file does not belong to the package
exit;
end;
end;
Cnt:=FileCount;
for i:=0 to Cnt-1 do begin
Result:=Files[i];
if (not FindVirtualFile) and (not FilenameIsAbsolute(Result.Filename)) then
continue;
if (CompareFilenames(Result.Filename,TheFilename)=0)
or (CompareFilenames(Result.GetFullFilename,TheFilename)=0) then
exit;
@ -3119,6 +3110,8 @@ begin
Cnt:=RemovedFilesCount;
for i:=0 to Cnt-1 do begin
Result:=RemovedFiles[i];
if (not FindVirtualFile) and (not FilenameIsAbsolute(Result.Filename)) then
continue;
if (CompareFilenames(Result.Filename,TheFilename)=0)
or (CompareFilenames(Result.GetFullFilename,TheFilename)=0) then
exit;

View File

@ -207,7 +207,7 @@ type
var File1: TPkgFile;
var ConflictPkg: TLazPackage): boolean;
function FindFileInAllPackages(const TheFilename: string;
IgnoreDeleted, FindNewFile: boolean): TPkgFile;
IgnoreDeleted, FindVirtualFile: boolean): TPkgFile;
procedure FindPossibleOwnersOfUnit(const TheFilename: string;
OwnerList: TFPList);
function FindLowestPkgNodeByName(const PkgName: string): TAVLTreeNode;
@ -1185,7 +1185,7 @@ begin
end;
function TLazPackageGraph.FindFileInAllPackages(const TheFilename: string;
IgnoreDeleted, FindNewFile: boolean): TPkgFile;
IgnoreDeleted, FindVirtualFile: boolean): TPkgFile;
var
Cnt: Integer;
i: Integer;
@ -1193,7 +1193,7 @@ begin
Cnt:=Count;
for i:=0 to Cnt-1 do begin
Result:=Packages[i].FindPkgFile(TheFilename,IgnoreDeleted,
FindNewFile);
FindVirtualFile);
if Result<>nil then exit;
end;
Result:=nil;

View File

@ -1641,6 +1641,10 @@ var
PkgFile: TPkgFile;
begin
Result:='';
if FilenameIsAbsolute(Filename) then begin
Result:=ExtractFilePath(Filename);
exit;
end;
PkgFile:=PackageGraph.FindFileInAllPackages(Filename,true,true);
if PkgFile=nil then exit;
APackage:=PkgFile.LazPackage;