Fix when typing `.` on helpers. or snippets.
This commit is contained in:
parent
e07cb6fb68
commit
cc0233eb04
|
@ -110,28 +110,13 @@ export const getHelperCompletions = (mode: {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const snippetAutoComplete = (snippets: Snippet[]): BindingCompletion => {
|
export const snippetAutoComplete = (snippets: Snippet[]): BindingCompletion => {
|
||||||
return function myCompletions(context: CompletionContext) {
|
return setAutocomplete(
|
||||||
if (!snippets?.length) {
|
snippets.map(snippet => ({
|
||||||
return null
|
section: buildSectionHeader("snippets", "Snippets", "Code", 100),
|
||||||
}
|
label: `snippets.${snippet.name}`,
|
||||||
|
displayLabel: snippet.name,
|
||||||
if (wrappedAutocompleteMatch(context)) {
|
}))
|
||||||
return null
|
)
|
||||||
}
|
|
||||||
|
|
||||||
const word = context.matchBefore(/\b\w*/)
|
|
||||||
if (!word || (word.from == word.to && !context.explicit)) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
from: word.from,
|
|
||||||
options: snippets.map(snippet => ({
|
|
||||||
section: buildSectionHeader("snippets", "Snippets", "Code", 100),
|
|
||||||
label: `snippets.${snippet.name}`,
|
|
||||||
displayLabel: snippet.name,
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bindingFilter = (options: BindingCompletionOption[], query: string) => {
|
const bindingFilter = (options: BindingCompletionOption[], query: string) => {
|
||||||
|
@ -211,27 +196,33 @@ export const jsAutocomplete = (
|
||||||
export const jsHelperAutocomplete = (
|
export const jsHelperAutocomplete = (
|
||||||
baseCompletions: BindingCompletionOption[]
|
baseCompletions: BindingCompletionOption[]
|
||||||
): BindingCompletion => {
|
): BindingCompletion => {
|
||||||
function coreCompletion(context: CompletionContext) {
|
return setAutocomplete(
|
||||||
|
baseCompletions.map(helper => ({
|
||||||
|
section: helper.section,
|
||||||
|
displayLabel: helper.label,
|
||||||
|
label: `helpers.${helper.label}()`,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setAutocomplete(
|
||||||
|
options: BindingCompletionOption[]
|
||||||
|
): BindingCompletion {
|
||||||
|
return function (context: CompletionContext) {
|
||||||
if (wrappedAutocompleteMatch(context)) {
|
if (wrappedAutocompleteMatch(context)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const word = context.matchBefore(/\b\w*/)
|
const word = context.matchBefore(/\b\w*(\.\w*)?/)
|
||||||
if (!word || (word.from == word.to && !context.explicit)) {
|
if (!word || (word.from == word.to && !context.explicit)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
from: word.from,
|
from: word.from,
|
||||||
options: baseCompletions.map(helper => ({
|
options,
|
||||||
section: helper.section,
|
|
||||||
displayLabel: helper.label,
|
|
||||||
label: `helpers.${helper.label}()`,
|
|
||||||
})),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return coreCompletion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildBindingInfoNode = (binding: {
|
const buildBindingInfoNode = (binding: {
|
||||||
|
|
Loading…
Reference in New Issue