fix: restore proper toggling of autocompleteOnTyping

This commit is contained in:
tophf 2021-03-13 08:53:43 +03:00
parent dfed35c1f4
commit b4cf010eee

View File

@ -27,20 +27,20 @@
const originalHelper = CodeMirror.hint.css || (() => {});
let cssMedia, cssProps, cssPropsValues;
const aot = prefs.get('editor.autocompleteOnTyping');
CodeMirror.defineOption('autocompleteOnTyping', aot, aotToggled);
if (aot) cmFactory.globalSetOption('autocompleteOnTyping', true);
const AOT_ID = 'autocompleteOnTyping';
const AOT_PREF_ID = 'editor.' + AOT_ID;
const aot = prefs.get(AOT_PREF_ID);
CodeMirror.defineOption(AOT_ID, aot, (cm, value) => {
cm[value ? 'on' : 'off']('changes', autocompleteOnTyping);
cm[value ? 'on' : 'off']('pick', autocompletePicked);
});
prefs.subscribe(AOT_PREF_ID, (key, val) => cmFactory.globalSetOption(AOT_ID, val), {runNow: aot});
CodeMirror.registerHelper('hint', 'css', helper);
CodeMirror.registerHelper('hint', 'stylus', helper);
tokenHooks['/'] = tokenizeUsoVariables;
function aotToggled(cm, value) {
cm[value ? 'on' : 'off']('changes', autocompleteOnTyping);
cm[value ? 'on' : 'off']('pick', autocompletePicked);
}
async function helper(cm) {
const pos = cm.getCursor();
const {line, ch} = pos;