Skip to content

Commit bbab14d

Browse files
committed
Low hanging functional fruit
1 parent 9a37ba1 commit bbab14d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/core/graph/widgets/dynamicWidgets.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,20 +368,21 @@ function applyAutogrow(node: LGraphNode, untypedInputSpec: InputSpecV2) {
368368
const trackedInputs: string[][] = []
369369
function addInputGroup(insertionIndex: number) {
370370
const ordinal = trackedInputs.length
371-
const inputGroup: string[] = []
372-
for (const input of inputsV2) {
373-
const namedSpec = {
374-
...input,
375-
name: names ? names[ordinal] : (prefix ?? '') + ordinal,
376-
isOptional: ordinal >= (min ?? 0) || input.isOptional
377-
}
378-
inputGroup.push(namedSpec.name)
379-
if (node.inputs.some((inp) => inp.name === namedSpec.name)) continue
380-
addNodeInput(node, namedSpec)
381-
const addedInput = spliceInputs(node, node.inputs.length - 1, 1)[0]
382-
spliceInputs(node, insertionIndex++, 0, addedInput)
383-
}
384-
trackedInputs.push(inputGroup)
371+
const inputGroup = inputsV2.map((input) => ({
372+
...input,
373+
name: names ? names[ordinal] : (prefix ?? '') + ordinal,
374+
isOptional: ordinal >= (min ?? 0) || input.isOptional
375+
}))
376+
const newInputs = inputGroup
377+
.filter(
378+
(namedSpec) => !node.inputs.some((inp) => inp.name === namedSpec.name)
379+
)
380+
.map((namedSpec) => {
381+
addNodeInput(node, namedSpec)
382+
return spliceInputs(node, node.inputs.length - 1, 1)[0]
383+
})
384+
spliceInputs(node, insertionIndex, 0, ...newInputs)
385+
trackedInputs.push(inputGroup.map((inp) => inp.name))
385386
app.canvas?.setDirty(true, true)
386387
}
387388
for (let i = 0; i < (min || 1); i++) addInputGroup(node.inputs.length)

0 commit comments

Comments
 (0)