Improve autocomplete triggers to make editing more intuitive

This commit is contained in:
David Evans 2017-11-22 18:52:35 +00:00
parent da7b03d3ed
commit ece11167f3
1 changed files with 6 additions and 8 deletions

View File

@ -145,17 +145,15 @@ define([
code.on('keydown', (cm, event) => {
lastKey = event.keyCode;
});
code.on('endCompletion', () => {
lastKey = 0;
});
code.on('change', (cm, change) => {
if(cm.state.completionActive || change.origin === 'library') {
return;
}
if(lastKey === 13 || lastKey === 8) {
return;
}
if(change.origin === '+input') {
if(lastKey === 13) {
lastKey = 0;
return;
}
} else if(change.origin !== 'complete') {
return;
}
CodeMirror.commands.autocomplete(cm, null, {
completeSingle: false,
});