sdk icon indicating copy to clipboard operation
sdk copied to clipboard

`Bind all parameters to fields` appears twice, mangles up code and places caret at wrong position

Open denniskaselow opened this issue 3 days ago • 2 comments

Using Dart SDK version: 3.11.0-190.0.dev (dev) (Mon Dec 1 04:03:43 2025 -0800) on "windows_x64"

The following code:

class Foo {
  Foo({required int foo, required int foobar});
}

shows two assists, both named "Bind all parameters to fields". with the second one only binding one parameter to a field. Image

But it looks like an assist with a correct text ("Bind parameter to field") exists: https://github.com/dart-lang/sdk/blob/a5fe41a609b33370e6e71848d472209d3a5c757c/pkg/analysis_server/lib/src/services/correction/assist.dart#L39-L48

Furthermore, selecting the second assist on foo, creates this:

Image

The placeholder-thingies where I can enter a different type or name are misplaced.

If I select the first "Bind all parameters to fields" assist, it creates this abomination:

class Foo {
  Foo({required this.foo, required this.bar});

is.nar}oo;

  int bar;
}

More parameters create a greater mess.

denniskaselow avatar Dec 08 '25 16:12 denniskaselow