testScript.ts 599 B

123456789101112131415161718192021222324
  1. import { Completer, CompletionEntry } from "."
  2. import { getTestScriptCompletions } from "~/helpers/tern"
  3. export const completer: Completer = async (text, completePos) => {
  4. const results = await getTestScriptCompletions(
  5. text,
  6. completePos.line,
  7. completePos.ch
  8. )
  9. const completions = results.completions.map((completion: any, i: number) => {
  10. return <CompletionEntry>{
  11. text: completion.name,
  12. meta: completion.isKeyword ? "keyword" : completion.type,
  13. score: results.completions.length - i,
  14. }
  15. })
  16. return {
  17. completions,
  18. }
  19. }
  20. export default completer