Menu

#208 CodeFormatter removes indentation from within comment

Closed
closed-fixed
None
5
2020-10-13
2020-08-19
Ralf Junker
No

Sometimes, the CodeFormatter removes paragraph indentation from within a comment if the IndentComments option is enabled.

The test case below demonstrates the problem. The formatter removes indentation from the 2nd paragraph. I can reproduce this with the formatter dunit tests and the FormatterSettings-Borland.ini setting, which has IndentComments enabled.

unit testfile_CommentIndent;

interface

{ 1st paragraph.
  2nd paragraph should stay indented. }
procedure p1;

implementation

end.

IMO, the formatter should not change the comment, and older GExperts did not do so. However, recent GExperts compiled from SVN show the new behavior. It might have been introduced in SVN 3083, which fixed wrong comment indentation before procedures. I welcome the fix in that it no longer adds indentation to entire comments before procedures, but I believe it should leave indentation within the comment itself unchanged.

Discussion

  • Ralf Junker

    Ralf Junker - 2020-08-19

    Attached testfile_CommentIndent.pas because the 2 paragraphs in the ticket above are not properly separated to demonstrate the problem.

    Generally speaking, CodeFormatter removes indentation from a commen's last paragraph, which is separated by two newlines. Earlier paragraphs stay properly indented.

     
  • Thomas Mueller

    Thomas Mueller - 2020-10-02
    • assigned_to: Thomas Mueller
     
  • Thomas Mueller

    Thomas Mueller - 2020-10-02

    This does not happen for all test configurations, only for:

    • Borland Formatting
    • Default Formatting

    todo: Check which setting causes this, maybe it's even as designed.

     
  • Thomas Mueller

    Thomas Mueller - 2020-10-03
     
  • Thomas Mueller

    Thomas Mueller - 2020-10-03

    It's the IndentComments setting. If set to true, the indentation will be removed, if set to false, it stays as it is. Not sure that this is a bug or not.

     
  • Thomas Mueller

    Thomas Mueller - 2020-10-04
    • status: open --> closed-fixed
    • Group: New --> Closed
     
  • Thomas Mueller

    Thomas Mueller - 2020-10-04

    The case wasn't covered in IndentProcedureComment
    fixed in revision #3345

     
  • Ralf Junker

    Ralf Junker - 2020-10-07

    Is it possible that the fix in revision #3345 introduced a glitch in another context?

    For this code, the formatter now outdents the 2nd line by removing two whitespace:

    case value of
     1,
      { 1st line.
        2nd line - will be outdented. }
      2:
        begin
        end;
    end;
    
     

    Last edit: Ralf Junker 2020-10-07
    • Thomas Mueller

      Thomas Mueller - 2020-10-09

      Please create a new bug report for this.

       
  • Ralf Junker

    Ralf Junker - 2020-10-13
     

    Last edit: Ralf Junker 2020-10-13

Log in to post a comment.