Split field and helpers

This commit is contained in:
Adria Navarro 2025-02-10 17:41:58 +01:00
parent 22d2eb2ff7
commit 59ed37a51f
2 changed files with 22 additions and 4 deletions

View File

@ -217,6 +217,25 @@ export const jsAutocomplete = (baseCompletions: BindingCompletion[]) => {
return coreCompletion
}
export const jsHelperAutocomplete = (baseCompletions: BindingCompletion[]) => {
async function coreCompletion(context: CompletionContext) {
let jsBinding = context.matchBefore(/\bhelpers\./)
let options = baseCompletions || []
if (jsBinding) {
return {
from: jsBinding.from + (jsBinding.to - jsBinding.from),
filter: false,
options,
}
}
return null
}
return coreCompletion
}
export const buildBindingInfoNode = (
completion: BindingCompletion,
binding: any

View File

@ -23,6 +23,7 @@
snippetAutoComplete,
EditorModes,
bindingsToCompletions,
jsHelperAutocomplete,
} from "../CodeEditor"
import BindingSidePanel from "./BindingSidePanel.svelte"
import EvaluationSidePanel from "./EvaluationSidePanel.svelte"
@ -114,10 +115,8 @@
useSnippets?: boolean
) => {
const completions: ((_: CompletionContext) => any)[] = [
jsAutocomplete([
...bindingCompletions,
...getHelperCompletions(EditorModes.JS),
]),
jsAutocomplete([...bindingCompletions.filter(c => c.label)]),
jsHelperAutocomplete([...getHelperCompletions(EditorModes.JS)]),
]
if (useSnippets && snippets) {
completions.push(snippetAutoComplete(snippets))