Skip to content

Code is completely de-indented when no line-wrapping solution is found #179

Open
@zaneduffield

Description

@zaneduffield

In the rare cases where no line-wrapping solution is found for a logical line, currently all the code is de-indented all the way to the margin.

A contrived example that triggers this behaviour is

type 
  A = (
    a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 
    a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 
    a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 
    a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 
  );

which is formatted like

type
A = (
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
);

The formatter does this because it has already messed with the spacing between tokens, even if they span different lines. This means that if the optimising line formatter did nothing on no solution found, then most of the wrapped lines would be put within one space of the margin anyway, because it's the thing that's supposed to set the indentation level; the most sensible 'default' indentation if the process has failed is zero.

I think in cases like this it would be better to disable formatting for the entire line, as if it were wrapped in {pasfmt off/on} comments. Yes this will make it inconsistent with the surrounding code, but it's an unlikely error case and it would always be worse to de-indent to the margin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions