Fix appLeft/appRight to discard nonmatching events

This commit is contained in:
alex 2022-04-17 18:28:55 +01:00
parent 28ebf6559e
commit 30b7429169

View file

@ -182,11 +182,13 @@ export class Pattern {
const event_vals = pat_val.query(state.setSpan(hap_func.wholeOrPart())); const event_vals = pat_val.query(state.setSpan(hap_func.wholeOrPart()));
for (const hap_val of event_vals) { for (const hap_val of event_vals) {
const new_whole = hap_func.whole; const new_whole = hap_func.whole;
const new_part = hap_func.part.intersection_e(hap_val.part); const new_part = hap_func.part.intersection(hap_val.part);
const new_value = hap_func.value(hap_val.value); if (new_part) {
const new_context = hap_val.combineContext(hap_func); const new_value = hap_func.value(hap_val.value);
const hap = new Hap(new_whole, new_part, new_value, new_context); const new_context = hap_val.combineContext(hap_func);
haps.push(hap); const hap = new Hap(new_whole, new_part, new_value, new_context);
haps.push(hap);
}
} }
} }
return haps; return haps;
@ -203,11 +205,13 @@ export class Pattern {
const hap_funcs = pat_func.query(state.setSpan(hap_val.wholeOrPart())); const hap_funcs = pat_func.query(state.setSpan(hap_val.wholeOrPart()));
for (const hap_func of hap_funcs) { for (const hap_func of hap_funcs) {
const new_whole = hap_val.whole; const new_whole = hap_val.whole;
const new_part = hap_func.part.intersection_e(hap_val.part); const new_part = hap_func.part.intersection(hap_val.part);
const new_value = hap_func.value(hap_val.value); if (new_part) {
const new_context = hap_val.combineContext(hap_func); const new_value = hap_func.value(hap_val.value);
const hap = new Hap(new_whole, new_part, new_value, new_context); const new_context = hap_val.combineContext(hap_func);
haps.push(hap); const hap = new Hap(new_whole, new_part, new_value, new_context);
haps.push(hap);
}
} }
} }
return haps; return haps;