Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(soup): fix shift click soup crash (#5970)

Seamusca3b15ed78f2
diff --git a/apps/web/src/features/next-soup/soup-view/soup-view.tsx b/apps/web/src/features/next-soup/soup-view/soup-view.tsx
index 70cac76c1e..f4f57f2c71 100644
--- a/apps/web/src/features/next-soup/soup-view/soup-view.tsx
+++ b/apps/web/src/features/next-soup/soup-view/soup-view.tsx
@@ -1072,16 +1072,27 @@ const SoupViewListContent = (props: SoupViewListProps) => {
return;
}
- const newEntitiesForSelection = [];
const sign = Math.sign(params.entityIndex - anchorIndex);
+ // Shift-clicking the anchor itself has zero range. Stepping the loop by
+ // `sign` (0) would spin forever, so just toggle the single entity.
+ if (sign === 0) {
+ soup.selection.toggle(params.entity);
+ lastClickedEntityId = params.entityIndex;
+ return;
+ }
+
+ const newEntitiesForSelection = [];
+
for (
let i = anchorIndex;
sign > 0 ? i <= params.entityIndex : i >= params.entityIndex;
i += sign
) {
+ // The anchor can be stale (rows changed since the last click), so guard
+ // against indexing past the current list.
const entity = entityList[i];
- if (!entity.isSelected()) {
+ if (entity && !entity.isSelected()) {
newEntitiesForSelection.push(entity.original);
}
}