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':
|
||||
editors.forEach(cm => {
|
||||
const onOff = el.checked ? 'on' : 'off';
|
||||
cm[onOff]('change', autocompleteOnTyping);
|
||||
cm[onOff]('changes', autocompleteOnTyping);
|
||||
cm[onOff]('pick', autocompletePicked);
|
||||
});
|
||||
return;
|
||||
|
@ -380,9 +380,9 @@ function setupCodeMirror(textarea, index) {
|
|||
const cm = CodeMirror.fromTextArea(textarea, {lint: null});
|
||||
const wrapper = cm.display.wrapper;
|
||||
|
||||
cm.on('change', indicateCodeChange);
|
||||
cm.on('changes', cm => debounce(indicateCodeChange, 200, cm));
|
||||
if (prefs.get('editor.autocompleteOnTyping')) {
|
||||
cm.on('change', autocompleteOnTyping);
|
||||
cm.on('changes', autocompleteOnTyping);
|
||||
cm.on('pick', autocompletePicked);
|
||||
}
|
||||
cm.on('blur', () => {
|
||||
|
@ -1019,7 +1019,7 @@ function toggleSectionHeight(cm) {
|
|||
}
|
||||
}
|
||||
|
||||
function autocompleteOnTyping(cm, info, debounced) {
|
||||
function autocompleteOnTyping(cm, [info], debounced) {
|
||||
if (
|
||||
cm.state.completionActive ||
|
||||
info.origin && !info.origin.includes('input') ||
|
||||
|
@ -1032,7 +1032,7 @@ function autocompleteOnTyping(cm, info, debounced) {
|
|||
return;
|
||||
}
|
||||
if (!debounced) {
|
||||
debounce(autocompleteOnTyping, 100, cm, info, true);
|
||||
debounce(autocompleteOnTyping, 100, cm, [info], true);
|
||||
return;
|
||||
}
|
||||
if (info.text.last.match(/[-\w!]+$/)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user