In the process of implementing a custom auto completion, when using completion, the tab key defaults to switching parameters and does not take effect. My completion options are as follows:
import {snippetCompletion} from '@codemirror/autocomplete';
import {CompletionsType} from '../interface';
export function customCompletions(completions: CompletionsType[])
{
return (context: any) =>
{
let word = context.matchBefore(/\w*/);
if (word.from == word.to && !context.explicit) return null;
return {
from: word.from,
options: completions?.map((item) => (
snippetCompletion(item.template,{
label: item.label,
detail: item.detail,
type: item.type,
})
)) || [],
};
};
}
// 以下是myCompletions:
[
{
label: 'if',
// eslint-disable-next-line no-template-curly-in-string
template: 'func.if(${p}, ${v1}, ${v2})',
detail: 'Judging function, where p is a condition, returns v1 when p is true, and v2 when p is false',
type: 'function',
handle: `(p, v1, v2) => {
return p ? v1 : v2;
}`,
},]
I have observed that after auto completion, the first Snippet is selected by default, and the tab key can switch between Snippets. However, when switching to the last parameter, the tab key will become indented. If I want to achieve the effect of switching between tabs in the editor, how can I implement it