Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
feat: test script auto completion for codemirror
Andrew Bastin8d67a0d95f9d
diff --git a/helpers/editor/completion/testScript.ts b/helpers/editor/completion/testScript.tsnew file mode 100644index 000000000..94ad4d53e--- /dev/null+++ b/helpers/editor/completion/testScript.ts@@ -0,0 +1,30 @@+import { convertIndexToLineCh } from "../utils"+import { Completer, CompletionEntry } from "."+import { getTestScriptCompletions } from "~/helpers/tern"++export const completer: Completer = async (text, completePos) => {+ const results = await getTestScriptCompletions(+ text,+ completePos.line,+ completePos.ch+ )++ const start = convertIndexToLineCh(text, results.start)+ const end = convertIndexToLineCh(text, results.end)++ const completions = results.completions.map((completion: any, i: number) => {+ return <CompletionEntry>{+ text: completion.name,+ meta: completion.isKeyword ? "keyword" : completion.type,+ score: results.completions.length - i,+ }+ })++ return {+ start,+ end,+ completions,+ }+}++export default completer