mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 05:38:34 +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
|
||||
*/
|
||||
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)));
|
||||
if (this.__pure !== undefined) {
|
||||
result.__pure = this.__pure;
|
||||
result.__pure_loc = this.__pure_loc;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -510,10 +513,15 @@ export class Pattern {
|
||||
start,
|
||||
end,
|
||||
};
|
||||
return this.withContext((context) => {
|
||||
const result = this.withContext((context) => {
|
||||
const locations = (context.locations || []).concat([location]);
|
||||
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)) {
|
||||
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 = result.withContext((context) => {
|
||||
const locations = (context.locations || []).concat(pureLocs);
|
||||
return { ...context, locations };
|
||||
});
|
||||
} else {
|
||||
const [left, ...right] = firstArgs;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user