From e9e078db858f3adb840f7cb83fc270d1da4ca3cf Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 9 Mar 2009 14:34:09 +0000 Subject: [PATCH] IDE: when renaming the main source, auto rename the project git-svn-id: trunk@18927 - --- ide/main.pp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ide/main.pp b/ide/main.pp index 576001944b..757608c276 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -7112,6 +7112,7 @@ var ActiveSrcEdit:TSourceEditor; ActiveUnitInfo:TUnitInfo; TestFilename, DestFilename: string; ResourceCode, LFMCode: TCodeBuffer; + MainUnitInfo: TUnitInfo; begin {$IFDEF IDE_VERBOSE} writeln('TMainIDE.DoSaveEditorFile A PageIndex=',PageIndex,' Flags=',SaveFlagsToString(Flags)); @@ -7155,6 +7156,22 @@ begin if (not (sfSaveToTestDir in Flags)) and (ActiveUnitInfo.IsVirtual) then Include(Flags,sfSaveAs); + // if this is the main source and has the same name as the lpi + // rename the project + // Note: + // Changing the main source file without the .lpi is possible only by + // manually editing the lpi file, because this is only needed in + // special cases. + MainUnitInfo:=ActiveUnitInfo.Project.MainUnitInfo; + if (sfSaveAs in Flags) and (not (sfProjectSaving in Flags)) + and (ActiveUnitInfo=MainUnitInfo) + and (CompareFilenames(ExtractFileNameWithoutExt(ActiveUnitInfo.Filename), + ExtractFileNameWithoutExt(MainUnitInfo.Filename))=0) then + begin + Result:=DoSaveProject([sfSaveAs]); + exit; + end; + // update source notebook page names if (not (sfProjectSaving in Flags)) then UpdateSourceNames;