in src/main/resources/assets/scaffold.js [11:34]
function autoComplete(editor) {
var Pos = CodeMirror.Pos, cur = editor.getCursor(), cur_token = editor.getTokenAt(cur);
var tokens = editor.getLine(cur.line).split(/[^a-zA-Z0-9._]/);
var token = tokens[tokens.length - 1];
if (cur_token.string == ".") cur_token.start++;
withInterpreter(function(interpreter) {
$.ajax({
type: 'POST',
url: interpreter + "/completions",
data: token,
}).done(function (result) {
var hints = {list: result, from: Pos(cur.line, cur_token.start), to: Pos(cur.line, cur_token.end)};
CodeMirror.showHint(editor, hints);
}).fail(function (xhr) {
if (xhr.status === 404) {
withNewInterpreter(function (interpreter) {
autoComplete(editor);
});
} else {
console.log("Unexpected failure")
}
});
});
}