diff --git a/main.js b/main.js index e4e288b..f0fd035 100644 --- a/main.js +++ b/main.js @@ -24,7 +24,8 @@ module.exports = class RibbonClasp extends Plugin { this.debouncedEnforce?.cancel(); const ribbon = this.getRibbon(); - if (ribbon && this.originalOnChange) { + // don't restore over someone else's patch, just go inert instead + if (ribbon && ribbon.onChange === this.wrapper) { ribbon.onChange = this.originalOnChange; } } @@ -56,12 +57,13 @@ module.exports = class RibbonClasp extends Plugin { const original = ribbon.onChange.bind(ribbon); this.originalOnChange = original; - ribbon.onChange = (save) => { + this.wrapper = (save) => { original(save); - if (save && !this.enforcing) { + if (save && !this.enforcing && !this.unloaded) { this.recordOrder(ribbon); } }; + ribbon.onChange = this.wrapper; } enforceOrder() {