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 ShortenFilename(var ExpandedFilename: string; UseUp: boolean);
procedure LongenFilename(var AFilename: string); procedure LongenFilename(var AFilename: string);
function FindPkgFile(const AFilename: string; function FindPkgFile(const AFilename: string;
IgnoreRemoved, FindNewFile: boolean): TPkgFile; IgnoreRemoved, FindVirtualFile: boolean): TPkgFile;
function FindUnitWithRegister(IgnorePkgFile: TPkgFile = nil): TPkgFile; function FindUnitWithRegister(IgnorePkgFile: TPkgFile = nil): TPkgFile;
function FindUnit(const TheUnitName: string): TPkgFile; function FindUnit(const TheUnitName: string): TPkgFile;
function FindUnit(const TheUnitName: string; IgnoreRemoved: boolean): TPkgFile; function FindUnit(const TheUnitName: string; IgnoreRemoved: boolean): TPkgFile;
@ -3086,8 +3086,8 @@ begin
Result:=FComponents.IndexOf(PkgComponent); Result:=FComponents.IndexOf(PkgComponent);
end; end;
function TLazPackage.FindPkgFile(const AFilename: string; function TLazPackage.FindPkgFile(const AFilename: string; IgnoreRemoved,
IgnoreRemoved, FindNewFile: boolean): TPkgFile; FindVirtualFile: boolean): TPkgFile;
var var
TheFilename: String; TheFilename: String;
Cnt: Integer; Cnt: Integer;
@ -3097,20 +3097,11 @@ begin
TheFilename:=AFilename; 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; Cnt:=FileCount;
for i:=0 to Cnt-1 do begin for i:=0 to Cnt-1 do begin
Result:=Files[i]; Result:=Files[i];
if (not FindVirtualFile) and (not FilenameIsAbsolute(Result.Filename)) then
continue;
if (CompareFilenames(Result.Filename,TheFilename)=0) if (CompareFilenames(Result.Filename,TheFilename)=0)
or (CompareFilenames(Result.GetFullFilename,TheFilename)=0) then or (CompareFilenames(Result.GetFullFilename,TheFilename)=0) then
exit; exit;
@ -3119,6 +3110,8 @@ begin
Cnt:=RemovedFilesCount; Cnt:=RemovedFilesCount;
for i:=0 to Cnt-1 do begin for i:=0 to Cnt-1 do begin
Result:=RemovedFiles[i]; Result:=RemovedFiles[i];
if (not FindVirtualFile) and (not FilenameIsAbsolute(Result.Filename)) then
continue;
if (CompareFilenames(Result.Filename,TheFilename)=0) if (CompareFilenames(Result.Filename,TheFilename)=0)
or (CompareFilenames(Result.GetFullFilename,TheFilename)=0) then or (CompareFilenames(Result.GetFullFilename,TheFilename)=0) then
exit; exit;

View File

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

View File

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