sdk icon indicating copy to clipboard operation
sdk copied to clipboard

`SourceFileEdit.edits` access through `sourceChange` keeps increasing `edits` list if `createEditsForImports` is set

Open FMorschel opened this issue 1 week ago • 8 comments

I've been doing some testing for a quick fix for my plugin that may help me understand what to do for https://github.com/dart-lang/sdk/issues/55946. I've hit a weird behaviour here that I wanted to confirm was either intended and documented somewhere, or that we could fix it.

After awaiting ChangeBuilder.addDartFileEdit, I've accessed builder.sourceChange.edits.first.edits on my Debug Console. And doing so a second time (or more, obviously) increases the edits length.

Image

But I could not find any indication that this was supposed to happen:

Image

If I save that call to a local variable and access that, it doesn't increase the number of edits there, so there may be something else here doing this. Given that our debugger may eagerly evaluate getters, I don't think this is a good behaviour to have.

CC @bwilkerson @srawlins @DanTup

FMorschel avatar Dec 02 '25 11:12 FMorschel