Odd formatting of expression functions.
Open
@joaopsazevedo is already working on this.
Since Nov 26, 2024.
- Dominant language
- Ada
- Stars
- 21
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Strange scenario here:
with Ada.Directories;
with Ada.Strings.Unbounded;
package Foo is
package AD renames Ada.Directories;
package ASU renames Ada.Strings.Unbounded;
type Site_Config is tagged limited record
Dry_Run : Boolean := True;
Site_Root : ASU.Unbounded_String;
end record;
function "+"(S : ASU.Unbounded_String) return String renames ASU.To_String;
function Root_Dir (Config : Site_Config) return String is (+Config.Site_Root & "/");
function Output_Dir (Config : Site_Config) return String is (+Config.Site_Root & "/html");
function Source_Dir (Config : Site_Config) return String is (+Config.Site_Root & "/md");
function Config_Dir (Config : Site_Config) return String is (+Config.Site_Root & "/config");
procedure Build_Site (Root : String);
end Foo;
The center lines with expression functions reformat split lines, even though I'd rather keep them together:
function Root_Dir (Config : Site_Config) return String
is (+Config.Site_Root & "/");
function Output_Dir (Config : Site_Config) return String
is (+Config.Site_Root & "/html");
function Source_Dir (Config : Site_Config) return String
is (+Config.Site_Root & "/md");
function Config_Dir (Config : Site_Config) return String
is (+Config.Site_Root & "/config");
This still occurs even with these Package settings:
package Format is
for Width ("Ada") use "120";
end Format;
This continuation of expression functions along the same line might not be wanted by everyone. With the old formatter, I could use --!pp off and --!pp on to ignore lines. While GnatFormat works great in a lot of situations, it'd be great if I could ignore lines to get the behavior I want.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.