Skip to content

Commit f96b716

Browse files
committed
object suggestions: group the same send/receive symbols together
1 parent ae083a5 commit f96b716

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

Source/Components/SuggestionComponent.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,28 @@ class SuggestionComponent final : public Component
11571157
}
11581158
}
11591159
}
1160-
return filteredSendReceives;
1160+
1161+
// Filter duplicates
1162+
SmallArray<SendReceiveEntry> deduplicated;
1163+
for (int i = filteredSendReceives.size() - 1; i >= 0; i--) {
1164+
auto symbol = wantSend ? filteredSendReceives[i].sendSymbol : filteredSendReceives[i].receiveSymbol;
1165+
SendReceiveEntry* alreadySeen = nullptr;
1166+
for (auto& s : deduplicated) {
1167+
auto seenSymbol = wantSend ? s.sendSymbol : s.receiveSymbol;
1168+
if (seenSymbol == symbol) {
1169+
alreadySeen = &s;
1170+
break;
1171+
}
1172+
}
1173+
if (alreadySeen) {
1174+
alreadySeen->name += ", " + filteredSendReceives[i].name;
1175+
filteredSendReceives.remove_at(i);
1176+
} else {
1177+
deduplicated.add(filteredSendReceives[i]);
1178+
}
1179+
}
1180+
1181+
return deduplicated;
11611182
}
11621183

11631184
void deselectAll()

0 commit comments

Comments
 (0)