Skip to content

Odd formatting of expression functions. #1

@pyjarrett

Description

@pyjarrett

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions