From 30b74291695e94ec8e18ce42954d820e6c883986 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 17 Apr 2022 18:28:55 +0100 Subject: [PATCH] Fix appLeft/appRight to discard nonmatching events --- packages/core/pattern.mjs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 71f9755a..b8239c17 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -182,11 +182,13 @@ export class Pattern { const event_vals = pat_val.query(state.setSpan(hap_func.wholeOrPart())); for (const hap_val of event_vals) { const new_whole = hap_func.whole; - const new_part = hap_func.part.intersection_e(hap_val.part); - const new_value = hap_func.value(hap_val.value); - const new_context = hap_val.combineContext(hap_func); - const hap = new Hap(new_whole, new_part, new_value, new_context); - haps.push(hap); + const new_part = hap_func.part.intersection(hap_val.part); + if (new_part) { + const new_value = hap_func.value(hap_val.value); + const new_context = hap_val.combineContext(hap_func); + const hap = new Hap(new_whole, new_part, new_value, new_context); + haps.push(hap); + } } } return haps; @@ -203,11 +205,13 @@ export class Pattern { const hap_funcs = pat_func.query(state.setSpan(hap_val.wholeOrPart())); for (const hap_func of hap_funcs) { const new_whole = hap_val.whole; - const new_part = hap_func.part.intersection_e(hap_val.part); - const new_value = hap_func.value(hap_val.value); - const new_context = hap_val.combineContext(hap_func); - const hap = new Hap(new_whole, new_part, new_value, new_context); - haps.push(hap); + const new_part = hap_func.part.intersection(hap_val.part); + if (new_part) { + const new_value = hap_func.value(hap_val.value); + const new_context = hap_val.combineContext(hap_func); + const hap = new Hap(new_whole, new_part, new_value, new_context); + haps.push(hap); + } } } return haps;