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 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 = ( export const buildBindingInfoNode = (
completion: BindingCompletion, completion: BindingCompletion,
binding: any binding: any

View File

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