diff options
Diffstat (limited to 'src/console/completion/hooks.ts')
-rw-r--r-- | src/console/completion/hooks.ts | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/console/completion/hooks.ts b/src/console/completion/hooks.ts index 3a2ec33..a2e8bde 100644 --- a/src/console/completion/hooks.ts +++ b/src/console/completion/hooks.ts @@ -170,16 +170,12 @@ export const getPropertyCompletions = async ( return [{ name: "Properties", items }]; }; -export const useCompletions = () => { +export const useCompletions = (source: string) => { const state = React.useContext(CompletionStateContext); const dispatch = React.useContext(CompletionDispatchContext); const commandLineParser = React.useMemo(() => new CommandLineParser(), []); const [completionTypes] = useGetCompletionTypes(); - const updateCompletions = React.useCallback((source: string) => { - dispatch(actions.setCompletionSource(source)); - }, []); - const queryCompletions = React.useCallback( (text: string, completionTypes: CompletionType[]) => { const phase = commandLineParser.inputPhase(text); @@ -233,16 +229,15 @@ export const useCompletions = () => { ); React.useEffect(() => { + dispatch(actions.setCompletionSource(source)); + if (typeof completionTypes === "undefined") { return; } - queryCompletions(state.completionSource, completionTypes); - }, [state.completionSource, completionTypes]); + queryCompletions(source, completionTypes); + }, [source, completionTypes]); - return { - completions: state.completions, - updateCompletions, - }; + return { completions: state.completions }; }; export const useSelectCompletion = () => { |