fix suggestion order
This commit is contained in:
parent
46baad7cf4
commit
1ff4b181ff
8 changed files with 91 additions and 168 deletions
|
|
@ -2,11 +2,11 @@ import { useContext, useEffect, useRef, useState } from "react";
|
|||
|
||||
import { getSymbol, getType, symbolFunction } from "dope2";
|
||||
|
||||
import { CallBlock, CallBlockNoSugar, type CallBlockState } from "./CallBlock";
|
||||
import { CallBlock, type CallBlockState } from "./CallBlock";
|
||||
import { InputBlock, type InputBlockState, type SuggestionType } from "./InputBlock";
|
||||
import { Type } from "./Type";
|
||||
import { evalEditorBlock } from "./eval";
|
||||
import { CommandContext } from "./CommandContext";
|
||||
import { evalEditorBlock, type ResolvedType } from "./eval";
|
||||
import { GlobalContext } from "./GlobalContext";
|
||||
import "./Editor.css";
|
||||
import { EnvContext } from "./EnvContext";
|
||||
import { LambdaBlock, type LambdaBlockState } from "./LambdaBlock";
|
||||
|
|
@ -25,10 +25,10 @@ export type SetStateFn<InType = EditorState, OutType = InType> = (state: InType)
|
|||
export interface State2Props<InType, OutType = InType> {
|
||||
state: InType;
|
||||
setState: (callback: SetStateFn<InType, OutType>) => void;
|
||||
suggestionPriority: (suggestion: ResolvedType) => number;
|
||||
}
|
||||
|
||||
interface EditorProps extends State2Props<EditorState> {
|
||||
suggestionPriority: (suggestion: SuggestionType) => number;
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ export function Editor({state, setState, onCancel, suggestionPriority}: EditorPr
|
|||
}
|
||||
}, [needCommand]);
|
||||
|
||||
const globalContext = useContext(CommandContext);
|
||||
const globalContext = useContext(GlobalContext);
|
||||
const onCommand = (e: React.KeyboardEvent) => {
|
||||
const commands = ['e', 't', 'Enter', 'Backspace', 'ArrowLeft', 'ArrowRight', 'Tab', 'l', 'L', '=', '.', 'c', 'a'];
|
||||
if (!commands.includes(e.key)) {
|
||||
|
|
@ -163,20 +163,11 @@ export function Editor({state, setState, onCancel, suggestionPriority}: EditorPr
|
|||
onCancel={onCancel}
|
||||
/>;
|
||||
case "call":
|
||||
if (globalContext?.syntacticSugar) {
|
||||
return <CallBlock
|
||||
state={state}
|
||||
setState={setState as (callback:(p:CallBlockState)=>EditorState)=>void}
|
||||
suggestionPriority={suggestionPriority}
|
||||
/>;
|
||||
}
|
||||
else {
|
||||
return <CallBlockNoSugar
|
||||
state={state}
|
||||
setState={setState as (callback:(p:CallBlockState)=>EditorState)=>void}
|
||||
suggestionPriority={suggestionPriority}
|
||||
/>;
|
||||
}
|
||||
return <CallBlock
|
||||
state={state}
|
||||
setState={setState as (callback:(p:CallBlockState)=>EditorState)=>void}
|
||||
suggestionPriority={suggestionPriority}
|
||||
/>;
|
||||
case "let":
|
||||
return <LetInBlock
|
||||
state={state}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue