Fix: isInit -> initialized

This commit is contained in:
eight 2017-11-09 12:44:30 +08:00
parent 29f5daa912
commit 3011ba836d

View File

@ -10,20 +10,24 @@ function createAppliesToLineWidget(cm) {
];
const THROTTLE_DELAY = 400;
let widgets = [];
let fromLine, toLine, gutterStyle, isInit;
let fromLine, toLine, gutterStyle;
let initialized = false;
return {toggle};
function toggle(state = !isInit) {
if (!isInit && state) {
function toggle(newState = !initialized) {
newState = Boolean(newState);
if (newState !== initialized) {
if (newState) {
init();
} else if (isInit && !state) {
} else {
uninit();
}
}
}
function init() {
isInit = true;
initialized = true;
gutterStyle = getComputedStyle(cm.getGutterElement());
fromLine = null;
@ -39,7 +43,7 @@ function createAppliesToLineWidget(cm) {
}
function uninit() {
isInit = false;
initialized = false;
widgets.forEach(clearWidget);
widgets.length = 0;