Skip to content

String interpolation only absorbs when nothing is in front of the antiquotation marker #266

@Atemu

Description

@Atemu

Description

When there is nothing before the antiquotation marker ${ (i.e. only string context indent), multi-line constructs are absorbed right behind the antiquotation marker as expected. When there is any string before the marker though, nothing is absorbed.

Repro'd on 923d379.

Small example input

''
  ${somefunc { multiple = true; attrs = false; }}

  short ${somefunc { multiple = true; attrs = false; }}

  loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong ${somefunc { multiple = true; attrs = false; }}
''

Expected output

''
  ${somefunc {
    multiple = true;
    attrs = false;
  }}

  short ${somefunc {
    multiple = true;
    attrs = false;
  }}

  loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong ${somefunc {
    multiple = true;
    attrs = false;
  }}
''

Or perhaps do wrap with the long prefix.

Perhaps splitting across lines should be a little less eager in string interpolations to begin with though so that the first two are just a single line unless that line becomes too long. There usually isn't the same expectation for many more elements to be added inside of an interpolation and it's usually worth the potential diff noise IMHO.

This would be ideal IMHO:

''
  ${somefunc { multiple = true; attrs = false; }}

  short ${somefunc { multiple = true; attrs = false; }}

  loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong ${
    somefunc {
      multiple = true;
      attrs = false;
    }
  }
''

Actual output

''
  ${somefunc {
    multiple = true;
    attrs = false;
  }}

  short ${
    somefunc {
      multiple = true;
      attrs = false;
    }
  }

  loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong ${
    somefunc {
      multiple = true;
      attrs = false;
    }
  }
''

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstyleStyle discussion

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions