Skip to content

Don't change alignment of // comments on consecutive rows #48

Open
@kwalrath

Description

@kwalrath

The formatter wants each // comment to start one space after the end of the line, but often comments are more readable if they're aligned. Would it be possible to detect when comments are aligned and continue to keep them aligned?

Input:

  assert(v.x == 2 && v.y == 3);         // v   == (2,3)
  assert((v+w).x == 4 && (v+w).y == 5); // v+w == (4,5)
  assert((v-w).x == 0 && (v-w).y == 1); // v-w == (0,1)

Output:

  assert(v.x == 2 && v.y == 3); // v   == (2,3)
  assert((v + w).x == 4 && (v + w).y == 5); // v+w == (4,5)
  assert((v - w).x == 0 && (v - w).y == 1); // v-w == (0,1)

Ideal:

  assert(v.x == 2 && v.y == 3);             // v   == (2,3)
  assert((v + w).x == 4 && (v + w).y == 5); // v+w == (4,5)
  assert((v - w).x == 0 && (v - w).y == 1); // v-w == (0,1)

This code is from https://github.com/dart-lang/dart-up-and-running-book/blob/master/code/ch02/vector.dart (part of a test for a snippet in Chapter 2).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions