debounce indicateCodeChange per cm

This commit is contained in:
tophf 2017-09-01 11:16:57 +03:00
parent 0a5d9d86bf
commit 8809384264

View File

@ -380,7 +380,7 @@ function setupCodeMirror(textarea, index) {
const cm = CodeMirror.fromTextArea(textarea, {lint: null});
const wrapper = cm.display.wrapper;
cm.on('changes', cm => debounce(indicateCodeChange, 200, cm));
cm.on('changes', indicateCodeChangeDebounced);
if (prefs.get('editor.autocompleteOnTyping')) {
cm.on('changes', autocompleteOnTyping);
cm.on('pick', autocompletePicked);
@ -469,6 +469,11 @@ function indicateCodeChange(cm) {
updateLintReportIfEnabled(cm);
}
function indicateCodeChangeDebounced(cm, ...args) {
clearTimeout(cm.state.stylusOnChangeTimer);
cm.state.stylusOnChangeTimer = setTimeout(indicateCodeChange, 200, cm, ...args);
}
function getSectionForChild(e) {
return e.closest('#sections > div');
}