Menu

#337 Formatter does not handle multi line string literals

Closed
closed-fixed
None
5
2023-12-03
2023-11-26
No

The formatter does not handle the multi line string literals introduced in Delphi 12:

const
  bla = '''
    first line
    seconde line
      indented third line
        fourth line even further indented
    last line, no longer indented
  ''';

gets formatted as:

const
  bla = '''
    first line
    seconde line
    indented third line
    fourth line even further indented
    last line, no longer indented
    ''';

The indentation of the third and fourth line gets removed.

There are possibly even more problems if the string contains semicolon or comma characters or reserved words.

Discussion

  • Thomas Mueller

    Thomas Mueller - 2023-11-26
     
  • Thomas Mueller

    Thomas Mueller - 2023-11-26

    added unit tests in revision #4110

     
  • Thomas Mueller

    Thomas Mueller - 2023-11-26
     
  • Thomas Mueller

    Thomas Mueller - 2023-11-26

    A workaround for now is to enclose these strings with the {(} and {)} comments that prevent formatting. But note that this only works as long as the string content does not contain these special comments itself.

     

    Last edit: Thomas Mueller 2023-11-26
  • Thomas Mueller

    Thomas Mueller - 2023-11-26
    • summary: Formatter does not handle multi line string constants --> Formatter does not handle multi line string literals
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -The formatter does not handle the multi line string constants introduced in Delphi 12:
    +The formatter does not handle the multi line string literals introduced in Delphi 12:
    
     ~~~
     const
    
    • status: open --> closed-fixed
    • Group: New --> Closed
     
  • Thomas Mueller

    Thomas Mueller - 2023-11-26

    fixed in revision #4112

     
  • Thomas Mueller

    Thomas Mueller - 2023-12-03

    re-opened: Turned out that I overlooked some unit tests that previously worked but are now broken.

     
  • Thomas Mueller

    Thomas Mueller - 2023-12-03

    Fixed again in revision #4115, let's hope this time for real.

     

Log in to post a comment.

MongoDB Logo MongoDB