From c7e5d8d44152d9e2b80f123f6ae77a807bad8a61 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 24 May 2024 11:40:23 +0200 Subject: [PATCH] codetools: fixed clearing include file link --- components/codetools/codecache.pas | 3 ++- ide/main.pp | 8 ++++++-- ide/unitinfodlg.pp | 10 +++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/components/codetools/codecache.pas b/components/codetools/codecache.pas index 48d36c76af..fd008f2972 100644 --- a/components/codetools/codecache.pas +++ b/components/codetools/codecache.pas @@ -1349,7 +1349,8 @@ end; function TCodeBuffer.GetLastIncludedByFile: string; begin Result:=FLastIncludedByFile; - if Result=Filename then Result:=''; + if CompareFilenames(Result,Filename)=0 then + Result:=''; end; procedure TCodeBuffer.SetFilename(Value: string); diff --git a/ide/main.pp b/ide/main.pp index f0905cf6e6..b4dd3bf651 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -5960,7 +5960,7 @@ var ActiveSrcEdit:TSourceEditor; UnitLineCountWithIncludes: LongInt; UnitLineCountParsed: LongInt; Code: TCodeBuffer; - CTTool: TCodeTool; + CTTool, aCodeTool: TCodeTool; TreeOfSourceCodes: TAVLTree; Node: TAVLTreeNode; SubCode: TCodeBuffer; @@ -6020,8 +6020,12 @@ begin TrimSearchPath(CodeToolBoss.GetIncludePathForDirectory(FileDir),FileDir), TrimSearchPath(CodeToolBoss.GetCompleteSrcPathForDirectory(FileDir),FileDir) ); - if ClearIncludedByFile then + if ClearIncludedByFile then begin ActiveUnitInfo.Source.LastIncludedByFile:=''; + CodeToolBoss.SourceCache.ClearIncludedByEntry(ActiveUnitInfo.Source.Filename); + CodeToolBoss.Explore(ActiveUnitInfo.Source,aCodeTool,false,true); + SaveIncludeLinks; + end; if (DlgResult=mrYes) and (ActiveUnitInfo.Source.LastIncludedByFile<>'') then DoGotoIncludeDirective; end; diff --git a/ide/unitinfodlg.pp b/ide/unitinfodlg.pp index b475a62779..31252d30f0 100644 --- a/ide/unitinfodlg.pp +++ b/ide/unitinfodlg.pp @@ -57,10 +57,10 @@ type PathsGroupBox: TGroupBox; procedure CodeToolsDefsButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); - procedure clearIncludedByClick(Sender: TObject); + procedure ClearIncludedByClick(Sender: TObject); private FFilePath: string; - function getIncludedBy: string; + function GetIncludedBy: string; end; function ShowUnitInfoDlg(const AnUnitName, AType: string; @@ -130,7 +130,7 @@ begin Result:=Dlg.ShowModal; ClearIncludedBy:=(Result in [mrOk,mrYes]) and (IncludedBy<>'') - and (Dlg.getIncludedBy=''); + and (Dlg.GetIncludedBy=''); Dlg.Free; end; @@ -166,12 +166,12 @@ begin GotoIncludeDirectiveButton.Caption:=lisMenuGotoIncludeDirective; end; -procedure TUnitInfoDialog.clearIncludedByClick(Sender: TObject); +procedure TUnitInfoDialog.ClearIncludedByClick(Sender: TObject); begin ListValues.Items[6].SubItems[0]:=''; end; -function TUnitInfoDialog.getIncludedBy: string; +function TUnitInfoDialog.GetIncludedBy: string; begin Result:=ListValues.Items[6].SubItems[0]; end;