This commit is contained in:
Liang Ding 2015-08-15 11:41:37 +08:00
parent 1d99c130da
commit 0a96f993fb
1 changed files with 25 additions and 3 deletions

View File

@ -235,11 +235,33 @@ var playground = {
playground.editor.on('changes', function (cm) { playground.editor.on('changes', function (cm) {
$("#url").html(""); $("#url").html("");
});
playground.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);
} }
} }