fix suggestion order
This commit is contained in:
parent
46baad7cf4
commit
1ff4b181ff
8 changed files with 91 additions and 168 deletions
13
src/eval.ts
13
src/eval.ts
|
|
@ -66,7 +66,7 @@ export function evalInputBlock(text: string, value: InputValueType, env): Resolv
|
|||
return {
|
||||
kind: found.kind || "value",
|
||||
...found,
|
||||
substitutions: new Map(),
|
||||
substitutions: found.substitutions || new Map(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -170,6 +170,7 @@ export function evalCallBlock(fn: EditorState, input: EditorState, env): Resolve
|
|||
export function evalLetInBlock(value: EditorState, name: string, inner: EditorState, env): ResolvedType {
|
||||
const valueResolved = evalEditorBlock(value, env);
|
||||
// console.log('eval', name, '...', valueResolved.kind, valueResolved.e);
|
||||
// const innerEnv = growEnv(env)(name)(valueResolved);
|
||||
const innerEnv = makeInnerEnv(env, name, valueResolved);
|
||||
return evalEditorBlock(inner, innerEnv);
|
||||
}
|
||||
|
|
@ -281,14 +282,8 @@ export function attemptParseLiteral(text: string, env): Dynamic[] {
|
|||
.filter(resolved => (resolved.kind !== "unknown" && resolved.kind !== "error")) as unknown as Dynamic[];
|
||||
}
|
||||
|
||||
export function scoreResolved(resolved: ResolvedType, outPriority: (s:SuggestionType) => number) {
|
||||
const bias = outPriority(['literal', '<computed>',
|
||||
{
|
||||
// @ts-ignore
|
||||
kind: "unknown",
|
||||
t: resolved.t,
|
||||
substitutions: new Map(),
|
||||
}]);
|
||||
export function scoreResolved(resolved: ResolvedType, outPriority: (s:ResolvedType) => number) {
|
||||
const bias = outPriority(resolved);
|
||||
|
||||
if (resolved.kind === "value") {
|
||||
return 1 + bias;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue