From e20bbbe39933a572468f6fcefcd4ad767db9bfc8 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 29 Oct 2017 15:43:55 +0000 Subject: [PATCH] codetools: fixed adding uses section to program git-svn-id: trunk@56232 - --- components/codetools/stdcodetools.pas | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index d4eac40c8c..0d174982c9 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -961,7 +961,7 @@ function TStandardCodeTool.AddUnitToSpecificUsesSection(UsesSection: TUsesSectio const NewUnitName, NewUnitInFile: string; SourceChangeCache: TSourceChangeCache; AsLast: boolean; CheckSpecialUnits: boolean): boolean; var - UsesNode, OtherUsesNode, SectionNode: TCodeTreeNode; + UsesNode, OtherUsesNode, SectionNode, Node: TCodeTreeNode; NewUsesTerm: string; InsertPos: integer; Junk: TAtomPosition; @@ -1047,8 +1047,11 @@ begin if InsertPos<1 then begin // not a unit (i.e. program) // => insert after title and directives - if SectionNode.Next<>nil then begin - InsertPos:=FindLineEndOrCodeInFrontOfPosition(SectionNode.Next.StartPos, + Node:=SectionNode.Next; + if (Node<>nil) and (Node.Desc=ctnSrcName) then + Node:=Node.NextSkipChilds; + if Node<>nil then begin + InsertPos:=FindLineEndOrCodeInFrontOfPosition(Node.StartPos, true); end else begin // program empty => add at end