use 'changes' event to reduce overhead upon replaceAll
This commit is contained in:
parent
ab97108e6f
commit
7f9c377d33
10
edit/edit.js
10
edit/edit.js
|
@ -355,7 +355,7 @@ function acmeEventListener(event) {
|
||||||
case 'autocompleteOnTyping':
|
case 'autocompleteOnTyping':
|
||||||
editors.forEach(cm => {
|
editors.forEach(cm => {
|
||||||
const onOff = el.checked ? 'on' : 'off';
|
const onOff = el.checked ? 'on' : 'off';
|
||||||
cm[onOff]('change', autocompleteOnTyping);
|
cm[onOff]('changes', autocompleteOnTyping);
|
||||||
cm[onOff]('pick', autocompletePicked);
|
cm[onOff]('pick', autocompletePicked);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -380,9 +380,9 @@ function setupCodeMirror(textarea, index) {
|
||||||
const cm = CodeMirror.fromTextArea(textarea, {lint: null});
|
const cm = CodeMirror.fromTextArea(textarea, {lint: null});
|
||||||
const wrapper = cm.display.wrapper;
|
const wrapper = cm.display.wrapper;
|
||||||
|
|
||||||
cm.on('change', indicateCodeChange);
|
cm.on('changes', cm => debounce(indicateCodeChange, 200, cm));
|
||||||
if (prefs.get('editor.autocompleteOnTyping')) {
|
if (prefs.get('editor.autocompleteOnTyping')) {
|
||||||
cm.on('change', autocompleteOnTyping);
|
cm.on('changes', autocompleteOnTyping);
|
||||||
cm.on('pick', autocompletePicked);
|
cm.on('pick', autocompletePicked);
|
||||||
}
|
}
|
||||||
cm.on('blur', () => {
|
cm.on('blur', () => {
|
||||||
|
@ -1019,7 +1019,7 @@ function toggleSectionHeight(cm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function autocompleteOnTyping(cm, info, debounced) {
|
function autocompleteOnTyping(cm, [info], debounced) {
|
||||||
if (
|
if (
|
||||||
cm.state.completionActive ||
|
cm.state.completionActive ||
|
||||||
info.origin && !info.origin.includes('input') ||
|
info.origin && !info.origin.includes('input') ||
|
||||||
|
@ -1032,7 +1032,7 @@ function autocompleteOnTyping(cm, info, debounced) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!debounced) {
|
if (!debounced) {
|
||||||
debounce(autocompleteOnTyping, 100, cm, info, true);
|
debounce(autocompleteOnTyping, 100, cm, [info], true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (info.text.last.match(/[-\w!]+$/)) {
|
if (info.text.last.match(/[-\w!]+$/)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user