formatMultiSelection function
Builds the combined paste string for a broadcast selection stack
(PLAN.md §6: "the paste string for a multi-selection lists all three
refs"). One compact ref per line — always multiline regardless of the
--format flag, since several distinct references don't have a
sensible single-line form the way one reference's optional detail
lines do.
Implementation
String formatMultiSelection(List<({Map<String, Object?> payload, String jsonPath})> items) {
return items
.map((({Map<String, Object?> payload, String jsonPath}) item) {
final Map<String, Object?> target =
item.payload['target'] as Map<String, Object?>? ?? const <String, Object?>{};
final String widget = (target['widget'] as String?) ?? 'Widget';
final String file = (target['file'] as String?) ?? '?';
final Object? line = target['line'];
return '[ref] $widget @ $file:$line · details: ${item.jsonPath}';
})
.join('\n');
}