Skip to content

Inconistent line-wrapping for procedural types with directives #256

@zaneduffield

Description

@zaneduffield

Consider the following series of (global) variable declarations.

var
  FuncCallConv:
      function(A: Integer): Integer; stdcall = nil;

  FuncCallConv2:
      function(A: Integer; B: Integer): Integer; stdcall = nil;

  FuncCallConv3:
      function(A: Integer; B: Integer; CC: Integer): Integer; stdcall = nil;

  FuncMultiDirective:
      function(A: Integer; B: Integer): Integer; cdecl varargs = nil;

While atypical, calling convention routine directives can be specified after an anonymous procedural type.
The formatting for these is a bit wonky (wrap_column=60):

var
  FuncCallConv:
      function(A: Integer): Integer; stdcall = nil;

  FuncCallConv2:
      function(A: Integer; B: Integer): Integer;
      stdcall = nil;

  FuncCallConv3:
      function(
          A: Integer;
          B: Integer;
          CC: Integer
      ): Integer; stdcall = nil;

  FuncMultiDirective:
      function(A: Integer; B: Integer): Integer; cdecl
      varargs = nil;

Compare this against the formatting for the equivalent declarations without the directives:

var
  Func: function(A: Integer; B: Integer): Integer = nil;

  Func2: function(A: Integer; BBBBBB: Integer): Integer =
      nil;

  Func3:
          function(
              A: Integer;
              BBBBBB: Integer;
              C: Integer
          ): Integer =
      nil;

I'm not sure exactly what the best formatting is for these cases, but I don't think this is it.

example in web demo

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions