mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-22 02:58:32 +00:00
Fix pure mini highlight (#994)
* preserve locations for pure values via mininotation * preserve weight
This commit is contained in:
parent
d99af7c4ad
commit
29cb6195b3
@ -451,7 +451,9 @@ export class Pattern {
|
|||||||
* @noAutocomplete
|
* @noAutocomplete
|
||||||
*/
|
*/
|
||||||
withHaps(func) {
|
withHaps(func) {
|
||||||
return new Pattern((state) => func(this.query(state), state));
|
const result = new Pattern((state) => func(this.query(state), state));
|
||||||
|
result.weight = this.weight;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -484,6 +486,7 @@ export class Pattern {
|
|||||||
const result = this.withHap((hap) => hap.setContext(func(hap.context)));
|
const result = this.withHap((hap) => hap.setContext(func(hap.context)));
|
||||||
if (this.__pure !== undefined) {
|
if (this.__pure !== undefined) {
|
||||||
result.__pure = this.__pure;
|
result.__pure = this.__pure;
|
||||||
|
result.__pure_loc = this.__pure_loc;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -510,10 +513,15 @@ export class Pattern {
|
|||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
};
|
};
|
||||||
return this.withContext((context) => {
|
const result = this.withContext((context) => {
|
||||||
const locations = (context.locations || []).concat([location]);
|
const locations = (context.locations || []).concat([location]);
|
||||||
return { ...context, locations };
|
return { ...context, locations };
|
||||||
});
|
});
|
||||||
|
if (this.__pure) {
|
||||||
|
result.__pure = this.__pure;
|
||||||
|
result.__pure_loc = location;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1608,7 +1616,12 @@ export function register(name, func, patternify = true, preserveWeight = false)
|
|||||||
|
|
||||||
if (firstArgs.every((arg) => arg.__pure != undefined)) {
|
if (firstArgs.every((arg) => arg.__pure != undefined)) {
|
||||||
const pureArgs = firstArgs.map((arg) => arg.__pure);
|
const pureArgs = firstArgs.map((arg) => arg.__pure);
|
||||||
|
const pureLocs = firstArgs.filter((arg) => arg.__pure_loc).map((arg) => arg.__pure_loc);
|
||||||
result = func(...pureArgs, pat);
|
result = func(...pureArgs, pat);
|
||||||
|
result = result.withContext((context) => {
|
||||||
|
const locations = (context.locations || []).concat(pureLocs);
|
||||||
|
return { ...context, locations };
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const [left, ...right] = firstArgs;
|
const [left, ...right] = firstArgs;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user