Skip to content

Commit 7c773f9

Browse files
authored
Fixed delay in synchronization of font size increment and decrement (#1609)
* Fix font resize #1396 * Improve readability * Remove deprecated code
1 parent 0947f30 commit 7c773f9

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

CodeEdit/Features/Settings/Models/AppSettings.swift

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,24 @@ struct AppSettings<T>: DynamicProperty where T: Equatable {
1515

1616
let keyPath: WritableKeyPath<SettingsData, T>
1717

18-
@available(*,
19-
deprecated,
20-
message: """
21-
Use init(_ keyPath:) instead, otherwise the view will be reevaluated on every settings change.
22-
"""
23-
)
24-
init() where T == SettingsData {
25-
self.keyPath = \.self
26-
self.settings = .init(\.settings)
27-
}
28-
2918
init(_ keyPath: WritableKeyPath<SettingsData, T>) {
3019
self.keyPath = keyPath
31-
let newKeyPath = (\EnvironmentValues.settings).appending(path: keyPath)
32-
self.settings = .init(newKeyPath)
20+
let settingsKeyPath = (\EnvironmentValues.settings).appending(path: keyPath)
21+
self.settings = Environment(settingsKeyPath)
3322
}
3423

3524
var wrappedValue: T {
3625
get {
37-
settings.wrappedValue
26+
Settings.shared.preferences[keyPath: keyPath]
3827
}
3928
nonmutating set {
4029
Settings.shared.preferences[keyPath: keyPath] = newValue
4130
}
4231
}
4332

4433
var projectedValue: Binding<T> {
45-
.init {
46-
settings.wrappedValue
34+
Binding {
35+
Settings.shared.preferences[keyPath: keyPath]
4736
} set: {
4837
Settings.shared.preferences[keyPath: keyPath] = $0
4938
}

CodeEdit/Features/WindowCommands/ViewCommands.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ struct ViewCommands: Commands {
4747

4848
Menu("Font Size") {
4949
Button("Increase") {
50-
if !(editorFontSize >= 288) {
50+
if editorFontSize < 288 {
5151
editorFontSize += 1
5252
}
53-
if !(terminalFontSize >= 288) {
53+
if terminalFontSize < 288 {
5454
terminalFontSize += 1
5555
}
5656
}
5757
.keyboardShortcut("+")
5858

5959
Button("Decrease") {
60-
if !(editorFontSize <= 1) {
60+
if editorFontSize > 1 {
6161
editorFontSize -= 1
6262
}
63-
if !(terminalFontSize <= 1) {
63+
if terminalFontSize > 1 {
6464
terminalFontSize -= 1
6565
}
6666
}

0 commit comments

Comments
 (0)