Menu

#218 const is not indented

open
Formatting (69)
5
2010-02-13
2010-02-13
Anonymous
No

a block of const definitions will not be indented in programs and libraries, only in units the indentation works.

program foo;

const
xxx = 1,
yyy = 0;

begin
end.

It will remove the spaces before the xxx and yyy. In libraries it works.

Discussion

  • Nobody/Anonymous

    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.

     
  • Paul Ishenin

    Paul Ishenin - 2010-02-16

    fixed in r827

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.