diff --git a/main.js b/main.js index 3b734fa..0f53b1d 100644 --- a/main.js +++ b/main.js @@ -13,6 +13,7 @@ function debounce(fn, wait) { module.exports = class RibbonOrderLock extends Plugin { async onload() { this.settings = Object.assign({ order: [] }, await this.loadData()); + this.enforcing = false; this.debouncedEnforce = debounce(() => this.enforceOrder(), 200); this.app.workspace.onLayoutReady(() => { @@ -40,7 +41,7 @@ module.exports = class RibbonOrderLock extends Plugin { ribbon.onChange = (save) => { original(save); - if (save) { + if (save && !this.enforcing) { this.recordOrder(ribbon); } }; @@ -68,7 +69,12 @@ module.exports = class RibbonOrderLock extends Plugin { if (changed) { ribbon.items.length = 0; ribbon.items.push(...sorted); - ribbon.onChange(true); + this.enforcing = true; + try { + ribbon.onChange(true); + } finally { + this.enforcing = false; + } } this.mergeNewItems(ribbon);