integrated-application-development / integrated-application-development/pasfmt

Inconistent line-wrapping for procedural types with directives

Open
#256 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
105
Forks
20
PR merge metrics
No merged PRs in 30d

Description

Consider the following series of (global) variable declarations.
```delphi
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`):
```delphi
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:
```delphi
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](https://integrated-application-development.github.io/pasfmt/?source=dmFyCiAgRnVuYzoKICAgICAgZnVuY3Rpb24oQTogSW50ZWdlcjsgQjogSW50ZWdlcik6IEludGVnZXIgPSBuaWw7CgogIEZ1bmMyOgogICAgICBmdW5jdGlvbihBOiBJbnRlZ2VyOyBCQkJCQkI6IEludGVnZXIpOiBJbnRlZ2VyID0gbmlsOwoKICBGdW5jMzoKICAgICAgZnVuY3Rpb24oQTogSW50ZWdlcjsgQkJCQkJCOiBJbnRlZ2VyOyBDOiBJbnRlZ2VyKTogSW50ZWdlciA9IG5pbDsKCiAgRnVuY0NhbGxDb252OgogICAgICBmdW5jdGlvbihBOiBJbnRlZ2VyKTogSW50ZWdlcjsgc3RkY2FsbCA9IG5pbDsKCiAgRnVuY0NhbGxDb252MjoKICAgICAgZnVuY3Rpb24oQTogSW50ZWdlcjsgQjogSW50ZWdlcik6IEludGVnZXI7IHN0ZGNhbGwgPSBuaWw7CgogIEZ1bmNDYWxsQ29udjM6CiAgICAgIGZ1bmN0aW9uKEE6IEludGVnZXI7IEI6IEludGVnZXI7IENDOiBJbnRlZ2VyKTogSW50ZWdlcjsgc3RkY2FsbCA9IG5pbDsKCiAgRnVuY011bHRpRGlyZWN0aXZlOgogICAgICBmdW5jdGlvbihBOiBJbnRlZ2VyOyBCOiBJbnRlZ2VyKTogSW50ZWdlcjsgY2RlY2wgdmFyYXJncyA9IG5pbDs%3D&settings=d3JhcF9jb2x1bW4gPSA2MApiZWdpbl9zdHlsZSA9ICJhdXRvIgplbmNvZGluZyA9ICJuYXRpdmUiCnVzZV90YWJzID0gZmFsc2UKdGFiX3dpZHRoID0gMgpjb250aW51YXRpb25faW5kZW50cyA9IDIKbGluZV9lbmRpbmcgPSAibmF0aXZlIgo%3D)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.