From cc251686f9208cf52dce4e44f23c6f07f19aee9d Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 2 Nov 2023 13:33:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20extensions=20toggle=20(#26?= =?UTF-8?q?5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Common/PHP/PhpExtension.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpmon/Common/PHP/PhpExtension.swift b/phpmon/Common/PHP/PhpExtension.swift index 44b8360..534b71e 100644 --- a/phpmon/Common/PHP/PhpExtension.swift +++ b/phpmon/Common/PHP/PhpExtension.swift @@ -67,7 +67,7 @@ class PhpExtension { self.name = String(fullPath.split(separator: "/").last!) // take last segment - self.enabled = !line.contains(";") + self.enabled = !line.starts(with: ";") self.file = file } @@ -76,7 +76,7 @@ class PhpExtension { You may need to restart the other services in order for this change to apply. */ func toggle() async { - let newLine = enabled + let newLine = !line.starts(with: ";") // DISABLED: Commented out line ? "; \(line)" // ENABLED: Line where the comment delimiter (;) is removed @@ -84,14 +84,14 @@ class PhpExtension { await sed(file: file, original: line, replacement: newLine) - enabled.toggle() + self.enabled = !newLine.starts(with: ";") + self.line = newLine if !isRunningTests { Task { @MainActor in MainMenu.shared.rebuild() } } - } // MARK: - Static Methods