Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions CodeEdit/Features/Settings/Models/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,24 @@ struct AppSettings<T>: DynamicProperty where T: Equatable {

let keyPath: WritableKeyPath<SettingsData, T>

@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<SettingsData, T>) {
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
}
}

var projectedValue: Binding<T> {
.init {
settings.wrappedValue
Binding {
Settings.shared.preferences[keyPath: keyPath]
} set: {
Settings.shared.preferences[keyPath: keyPath] = $0
}
Expand Down
8 changes: 4 additions & 4 deletions CodeEdit/Features/WindowCommands/ViewCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down