feat: graphql language improvements

This commit is contained in:
Andrew Bastin
2021-11-13 20:14:58 +05:30
parent ca40cc5271
commit e88c40db0a
3 changed files with 31 additions and 10 deletions

View File

@@ -48,10 +48,19 @@ const hoppCompleterExt = (completer: Completer): Extension => {
// Expensive operation! Disable on bigger files ?
const text = context.state.doc.toJSON().join(context.state.lineBreak)
const line = context.state.doc.lineAt(context.pos).from
const ch = context.pos - line
const line = context.state.doc.lineAt(context.pos)
const lineStart = line.from
const lineNo = line.number - 1
const ch = context.pos - lineStart
const result = await completer(text, { line, ch })
// Only do trigger on type when typing a word token, else stop (unless explicit)
if (!context.matchBefore(/\w+/) && !context.explicit)
return {
from: context.pos,
options: [],
}
const result = await completer(text, { line: lineNo, ch })
// Use more completion features ?
const completions =