diff --git a/packages/core/repl.mjs b/packages/core/repl.mjs index 171697eb..bcb70eec 100644 --- a/packages/core/repl.mjs +++ b/packages/core/repl.mjs @@ -152,9 +152,9 @@ export function repl({ // allows muting a pattern x with x_ or _x return silence; } - if (id === '$') { + if (id.includes('$')) { // allows adding anonymous patterns with $: - id = `$${anonymousIndex}`; + id = `${id}${anonymousIndex}`; anonymousIndex++; } pPatterns[id] = this; @@ -215,8 +215,19 @@ export function repl({ let { pattern, meta } = await _evaluate(code, transpiler, transpilerOptions); if (Object.keys(pPatterns).length) { let patterns = []; + let soloActive = false; for (const [key, value] of Object.entries(pPatterns)) { - patterns.push(value.withState((state) => state.setControls({ id: key }))); + // handle soloed patterns ex: S$: s("bd!4") + const isSolod = key.length > 1 && key.startsWith('S'); + if (isSolod && soloActive === false) { + // first time we see a soloed pattern, clear existing patterns + patterns = []; + soloActive = true; + } + if (!soloActive || (soloActive && isSolod)) { + const valWithState = value.withState((state) => state.setControls({ id: key })); + patterns.push(valWithState); + } } if (eachTransform) { // Explicit lambda so only element (not index and array) are passed