From 88093842646b01b0113ec86bed6d75cadd1c02df Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 1 Sep 2017 11:16:57 +0300 Subject: [PATCH] debounce indicateCodeChange per cm --- edit/edit.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/edit/edit.js b/edit/edit.js index b1a99462..046bcf6f 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -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'); }