From 0983970abf8d884e71d434521ad30c9c443910f5 Mon Sep 17 00:00:00 2001 From: bdeshi Date: Sun, 2 Aug 2026 01:50:20 +0600 Subject: [PATCH] leave onChange alone if another plugin patched it after us --- main.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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() {