I spent a few hours with the code (i used the copy that is found in recent SVN versions of Lazarus, since i don't have Delphi) and it seems i have found the reason and have already a fix.
The bug (and my fix) will ONLY come into effect when "indent procedures in library" is DISABLED.
Here is the fix (based on current Lazarus sources):
C:\lazarus\components\jcf2\Process\Indent\Indenter.pas
starting in line 113:
> > function InGlobalTypeOrVarSection(const pt: TSourceToken): Boolean;
> > begin
> > // are we in a type or var section?
> > if not pt.HasParentNode([nTypeSection, nVarSection]) then
> > begin
change this to:
> > function InGlobalTypeOrVarSection(const pt: TSourceToken): Boolean;
> > begin
> > // are we in a type or var section?
> > // EXPERIMENTAL: added CONST section to this list,
> > // maybe rename the whole function now? It is used only once.
> > if not pt.HasParentNode([nTypeSection, nVarSection, nConstSection]) then
> > begin
This is only called once near the end of the file at line 638 and seems
to be part of another prior bugfix. The bug in the bugfix 1898723 and my
fix for the fix will only ever happen if the setting "indent for
procedures in library" is DISabled, else all this code won't be executed
at all.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I spent a few hours with the code (i used the copy that is found in recent SVN versions of Lazarus, since i don't have Delphi) and it seems i have found the reason and have already a fix.
The bug (and my fix) will ONLY come into effect when "indent procedures in library" is DISABLED.
Here is the fix (based on current Lazarus sources):
C:\lazarus\components\jcf2\Process\Indent\Indenter.pas
starting in line 113:
> > function InGlobalTypeOrVarSection(const pt: TSourceToken): Boolean;
> > begin
> > // are we in a type or var section?
> > if not pt.HasParentNode([nTypeSection, nVarSection]) then
> > begin
change this to:
> > function InGlobalTypeOrVarSection(const pt: TSourceToken): Boolean;
> > begin
> > // are we in a type or var section?
> > // EXPERIMENTAL: added CONST section to this list,
> > // maybe rename the whole function now? It is used only once.
> > if not pt.HasParentNode([nTypeSection, nVarSection, nConstSection]) then
> > begin
This is only called once near the end of the file at line 638 and seems
to be part of another prior bugfix. The bug in the bugfix 1898723 and my
fix for the fix will only ever happen if the setting "indent for
procedures in library" is DISabled, else all this code won't be executed
at all.
fixed in r827