I implemented Autocompletion in my editor and it is working fine.
But if I try to trigger it within parentheses, i.e.
drawCircle(mou|
the autocompletion is not triggered (it should show “mouse”). Outside the brackets it works.
I think I found the problem in the matchBefore-method in codemirror/autocomplete:
matchBefore(expr) {
let line = this.state.doc.lineAt(this.pos);
let start = Math.max(line.from, this.pos - 250);
let str = line.text.slice(start - line.from, this.pos - line.from);
let found = str.search(ensureAnchor(expr, false));
return found < 0 ? null : { from: start + found, to: this.pos, text: str.slice(found) };
}
This yields the whole string ‘drawCircle(mou’ and therefore the autocompletion for ‘mouse’ is not triggered.
I think there should be an option to configure the autocomplete package to define delimiter-characters such that you can specify to break at such characters like ‘(’ or ‘,’. Another solution would be to set the hard-coded 250 to 0.
You can find my editor here. Just type ‘mou’ in a free line and you will get the hints. If you type ‘drawCircle(mou’ there won’t be a completion.
I do not pass anything, the package does this on its own.
I think, this (showing no hints if caret is in brackets) is standard behaviour of CM 6, isn’t it?