From 73e5110f6cf4e9e52345c4e63b33179907b5be76 Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Wed, 12 Feb 2025 00:44:28 +1300 Subject: [PATCH] Styles: Fix disabling styles + order of operations when returning if the style was disabled I have no idea how I didn't catch this sooner. --- src/api/Styles.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/api/Styles.ts b/src/api/Styles.ts index eee93e29d..78bfcb962 100644 --- a/src/api/Styles.ts +++ b/src/api/Styles.ts @@ -51,13 +51,12 @@ function findDocuments() { export function enableStyle(style: Style | string) { if (typeof style === "string") style = requireStyle(style); + const previousState = style.enabled; + style.enabled = true; compileStyle(style); - if (style.enabled) - return false; - - return true; + return !previousState; } /** @@ -74,13 +73,12 @@ export function disableStyle(style: Style | string) { } } - compileStyle(style); - - if (!style.enabled) - return false; + const previousState = style.enabled; style.enabled = false; - return true; + compileStyle(style); + + return previousState; } /**