mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 18:58:17 +02:00
IDE: project loading: auto repair EditorIndex
git-svn-id: trunk@20543 -
This commit is contained in:
parent
176f0a934d
commit
e67a902cf7
16
ide/main.pp
16
ide/main.pp
@ -11248,6 +11248,8 @@ begin
|
||||
Include(OpenFlags,ofVirtualFile);
|
||||
end;
|
||||
|
||||
debugln(['TMainIDE.DoJumpToCompilerMessage SearchedFilename=',SearchedFilename]);
|
||||
|
||||
if SearchedFilename<>'' then begin
|
||||
// open the file in the source editor
|
||||
Result:=(DoOpenEditorFile(SearchedFilename,-1,OpenFlags)=mrOk);
|
||||
@ -11480,6 +11482,9 @@ begin
|
||||
exit;
|
||||
end;
|
||||
Result:='';
|
||||
|
||||
debugln(['TMainIDE.FindUnitFile AAA1 ',AFilename]);
|
||||
|
||||
// search in virtual (unsaved) files
|
||||
AnUnitInfo:=Project1.UnitInfoWithFilename(AFilename,
|
||||
[pfsfOnlyProjectFiles,pfsfOnlyVirtualFiles]);
|
||||
@ -11489,12 +11494,11 @@ begin
|
||||
end;
|
||||
// search in search path
|
||||
AnUnitName:=ExtractFileNameOnly(AFilename);
|
||||
if not Project1.IsVirtual then begin
|
||||
// use the CodeTools way to find the pascal source
|
||||
ProjectDir:=Project1.ProjectDirectory;
|
||||
Result:=CodeToolBoss.DirectoryCachePool.FindUnitInDirectory(ProjectDir,AnUnitName,true);
|
||||
if Result<>'' then exit;
|
||||
end;
|
||||
// use the CodeTools way to find the pascal source
|
||||
ProjectDir:=Project1.ProjectDirectory;
|
||||
debugln(['TMainIDE.FindUnitFile ',AnUnitName,' ',projectdir]);
|
||||
Result:=CodeToolBoss.DirectoryCachePool.FindUnitInDirectory(ProjectDir,AnUnitName,true);
|
||||
if Result<>'' then exit;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -638,6 +638,7 @@ type
|
||||
procedure ClearSourceDirectories;
|
||||
procedure SourceDirectoriesChanged(Sender: TObject);
|
||||
procedure EmbeddedObjectModified(Sender: TObject);
|
||||
procedure FixEditorIndex;
|
||||
protected
|
||||
function GetMainFile: TLazProjectFile; override;
|
||||
function GetMainFileID: Integer; override;
|
||||
@ -903,6 +904,9 @@ function dbgs(Types: TUnitCompDependencyTypes): string; overload;
|
||||
function dbgs(Flag: TUnitInfoFlag): string; overload;
|
||||
function dbgs(Flags: TUnitInfoFlags): string; overload;
|
||||
|
||||
function CompareUnitInfoWithEditorIndex(Unit1, Unit2: TUnitInfo): integer;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
const
|
||||
@ -958,6 +962,11 @@ begin
|
||||
Result:='['+Result+']';
|
||||
end;
|
||||
|
||||
function CompareUnitInfoWithEditorIndex(Unit1, Unit2: TUnitInfo): integer;
|
||||
begin
|
||||
Result:=Unit1.EditorIndex-Unit2.EditorIndex;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TUnitInfo Constructor
|
||||
------------------------------------------------------------------------------}
|
||||
@ -2557,6 +2566,7 @@ begin
|
||||
end;
|
||||
|
||||
finally
|
||||
FixEditorIndex;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
@ -3310,6 +3320,37 @@ begin
|
||||
Modified := True;
|
||||
end;
|
||||
|
||||
procedure TProject.FixEditorIndex;
|
||||
var
|
||||
List: TFPList;
|
||||
AnUnitInfo: TUnitInfo;
|
||||
i: Integer;
|
||||
NewActiveEditorIndexAtStart: LongInt;
|
||||
begin
|
||||
List:=TFPList.Create;
|
||||
try
|
||||
AnUnitInfo:=FirstUnitWithEditorIndex;
|
||||
while AnUnitInfo<>nil do
|
||||
begin
|
||||
List.Add(AnUnitInfo);
|
||||
AnUnitInfo:=AnUnitInfo.NextUnitWithEditorIndex;
|
||||
end;
|
||||
List.Sort(TListSortCompare(@CompareUnitInfoWithEditorIndex));
|
||||
NewActiveEditorIndexAtStart:=-1;
|
||||
for i:=0 to List.Count-1 do
|
||||
begin
|
||||
AnUnitInfo:=TUnitInfo(List[i]);
|
||||
if (NewActiveEditorIndexAtStart<0)
|
||||
and (ActiveEditorIndexAtStart=AnUnitInfo.EditorIndex) then
|
||||
NewActiveEditorIndexAtStart:=i;
|
||||
AnUnitInfo.EditorIndex:=i;
|
||||
end;
|
||||
ActiveEditorIndexAtStart:=NewActiveEditorIndexAtStart;
|
||||
finally
|
||||
List.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TProject.GetFirstAutoRevertLockedUnit: TUnitInfo;
|
||||
begin
|
||||
Result:=fFirst[uilAutoRevertLocked];
|
||||
|
Loading…
Reference in New Issue
Block a user