From 49ac131044f5202069f2202dea5ca0cd16a5257b Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 14 Oct 2021 13:07:16 -0600 Subject: [PATCH] fix: prevent crash with Monocle and monocleMinimizeRest when closing transient dialogs; ref #110 --- src/controller/index.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/controller/index.ts b/src/controller/index.ts index 119e91d5..068d6dec 100644 --- a/src/controller/index.ts +++ b/src/controller/index.ts @@ -243,13 +243,19 @@ export class TilingController implements Controller { this.engine.arrange(); // Switch to next window if monocle with config.monocleMinimizeRest - if (!this.currentWindow && this.engine.isLayoutMonocleAndMinimizeRest()) { - this.engine.focusOrder(1, true); - /* HACK: force window to maximize if it isn't already - * This is ultimately to trigger onWindowFocused() at the right time - */ - this.engine.focusOrder(1, true); - this.engine.focusOrder(-1, true); + try { + if (!this.currentWindow && this.engine.isLayoutMonocleAndMinimizeRest()) { + this.engine.focusOrder(1, true); + /* HACK: force window to maximize if it isn't already + * This is ultimately to trigger onWindowFocused() at the right time + */ + this.engine.focusOrder(1, true); + this.engine.focusOrder(-1, true); + } + } catch { + /* HACK for the HACK: transient modals cause an error with the above workaround, + * so if we catch it here and ignore it, all is well */ + return; } }