This commit is contained in:
Liang Ding 2015-08-15 11:34:18 +08:00
parent 012eab83c7
commit 1d99c130da
1 changed files with 26 additions and 4 deletions

View File

@ -866,11 +866,33 @@ var editors = {
$span.addClass("changed"); $span.addClass("changed");
} }
}); });
});
editor.on('keydown', function (cm, evt) {
if (evt.altKey || evt.ctrlKey || evt.shiftKey) {
return;
}
var k = evt.which;
if (k < 48) {
return;
}
// hit [0-9]
if (k > 57 && k < 65) {
return;
}
// hit [a-z]
if (k > 90) {
return;
}
if (config.autocomplete) { if (config.autocomplete) {
var curLine = cm.doc.getLine(cm.getCursor().line).trim().replace(/\W/, ""); if (0.5 <= Math.random()) {
if (1 === curLine.length || 0.5 <= Math.random() && "" !== curLine && /^\w+$/.test(curLine)) {
CodeMirror.commands.autocompleteAfterDot(cm); CodeMirror.commands.autocompleteAfterDot(cm);
} }
} }