Skip to content

Commit

Permalink
Allow data_insertatlist to add new items
Browse files Browse the repository at this point in the history
Resolves #2
  • Loading branch information
valadaptive committed Jun 2, 2024
1 parent 78cf1cb commit 34065d1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2096,7 +2096,8 @@ export const data_insertatlist = new ProtoBlock({
const item = ctx.evaluateFast(ITEM);
const index = ctx.evaluateFast(INDEX);
const list = ctx.lookupOrCreateList(LIST.value);
const numIndex = toListIndex(index, list.length);
// Allow new items to be inserted 1 past the end of the list
const numIndex = toListIndex(index, list.length + 1);
if (numIndex !== 0) list.splice(numIndex - 1, 0, item);
},
colorCategory: 'data_lists',
Expand Down

0 comments on commit 34065d1

Please sign in to comment.