Split field and helpers
This commit is contained in:
parent
22d2eb2ff7
commit
59ed37a51f
|
@ -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
|
||||||
|
|
|
@ -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))
|
||||||
|
|
Loading…
Reference in New Issue