From e7d1e524c426d3891ca2ba76d1a9f6521961b6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0brahim=20=C3=87etin?= Date: Sun, 10 Mar 2024 10:30:58 +0300 Subject: [PATCH 1/3] Fix font resize #1396 --- CodeEdit/Features/Settings/Models/AppSettings.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CodeEdit/Features/Settings/Models/AppSettings.swift b/CodeEdit/Features/Settings/Models/AppSettings.swift index b3d4757e2e..997d756284 100644 --- a/CodeEdit/Features/Settings/Models/AppSettings.swift +++ b/CodeEdit/Features/Settings/Models/AppSettings.swift @@ -28,13 +28,13 @@ Use init(_ keyPath:) instead, otherwise the view will be reevaluated on every se init(_ keyPath: WritableKeyPath) { self.keyPath = keyPath - let newKeyPath = (\EnvironmentValues.settings).appending(path: keyPath) - self.settings = .init(newKeyPath) + let settingsKeyPath = (\EnvironmentValues.settings).appending(path: keyPath) + self.settings = Environment(settingsKeyPath) } var wrappedValue: T { get { - settings.wrappedValue + Settings.shared.preferences[keyPath: keyPath] } nonmutating set { Settings.shared.preferences[keyPath: keyPath] = newValue @@ -42,8 +42,8 @@ Use init(_ keyPath:) instead, otherwise the view will be reevaluated on every se } var projectedValue: Binding { - .init { - settings.wrappedValue + Binding { + Settings.shared.preferences[keyPath: keyPath] } set: { Settings.shared.preferences[keyPath: keyPath] = $0 } From 995498b748a0663d8ea72cbf6010df0774d61762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0brahim=20=C3=87etin?= Date: Sun, 10 Mar 2024 10:31:25 +0300 Subject: [PATCH 2/3] Improve readability --- CodeEdit/Features/WindowCommands/ViewCommands.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index 685c5360eb..9c8fb9e463 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -47,20 +47,20 @@ struct ViewCommands: Commands { Menu("Font Size") { Button("Increase") { - if !(editorFontSize >= 288) { + if editorFontSize < 288 { editorFontSize += 1 } - if !(terminalFontSize >= 288) { + if terminalFontSize < 288 { terminalFontSize += 1 } } .keyboardShortcut("+") Button("Decrease") { - if !(editorFontSize <= 1) { + if editorFontSize > 1 { editorFontSize -= 1 } - if !(terminalFontSize <= 1) { + if terminalFontSize > 1 { terminalFontSize -= 1 } } From fabaffd54650e03448b767e01a53ca4362770dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0brahim=20=C3=87etin?= Date: Sun, 10 Mar 2024 10:32:05 +0300 Subject: [PATCH 3/3] Remove deprecated code --- CodeEdit/Features/Settings/Models/AppSettings.swift | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CodeEdit/Features/Settings/Models/AppSettings.swift b/CodeEdit/Features/Settings/Models/AppSettings.swift index 997d756284..d7a115df37 100644 --- a/CodeEdit/Features/Settings/Models/AppSettings.swift +++ b/CodeEdit/Features/Settings/Models/AppSettings.swift @@ -15,17 +15,6 @@ struct AppSettings: DynamicProperty where T: Equatable { let keyPath: WritableKeyPath - @available(*, - deprecated, - message: """ -Use init(_ keyPath:) instead, otherwise the view will be reevaluated on every settings change. -""" - ) - init() where T == SettingsData { - self.keyPath = \.self - self.settings = .init(\.settings) - } - init(_ keyPath: WritableKeyPath) { self.keyPath = keyPath let settingsKeyPath = (\EnvironmentValues.settings).appending(path: keyPath)