Fix: hook/unhook -> enableForEditor/disableForEditor

This commit is contained in:
eight 2018-09-02 14:27:52 +08:00
parent 47c6834331
commit 0482ac5ee0
3 changed files with 8 additions and 8 deletions

View File

@ -10,8 +10,8 @@ var linter = (() => {
return {
register,
refresh,
hook,
unhook,
enableForEditor,
disableForEditor,
onChange,
onUnhook
};
@ -30,12 +30,12 @@ var linter = (() => {
}
}
function hook(cm) {
function enableForEditor(cm) {
cm.setOption('lint', {onUpdateLinting, getAnnotations});
cms.add(cm);
}
function unhook(cm) {
function disableForEditor(cm) {
cm.setOption('lint', false);
cms.delete(cm);
for (const cb of unhookCallbacks) {

View File

@ -151,7 +151,7 @@ function addSection(event, section) {
sections.appendChild(div);
cm = setupCodeMirror(div, code);
}
linter.hook(cm);
linter.enableForEditor(cm);
linterReport.refresh();
div.CodeMirror = cm;
setCleanSection(div);
@ -481,7 +481,7 @@ function removeSection(event) {
setCleanItem(section, false);
updateTitle();
cm.focus();
linter.hook(cm);
linter.enableForEditor(cm);
linterReport.refresh();
};
section.insertAdjacentElement('afterend', stub);
@ -489,7 +489,7 @@ function removeSection(event) {
setCleanItem($('#sections'), false);
removeAreaAndSetDirty(section);
editors.splice(editors.indexOf(cm), 1);
linter.unhook(cm);
linter.disableForEditor(cm);
linterReport.refresh();
}

View File

@ -62,7 +62,7 @@ function createSourceEditor(style) {
updateMeta();
});
linter.hook(cm);
linter.enableForEditor(cm);
updateMeta().then(() => {