Skip to content

Commit 0de7f93

Browse files
committed
Fix: Additional onChange deprecation warnings
- Fixed remaining onChange(of:perform:) calls that used explicit 'perform:' label - Updated onChange calls with capture lists to use new two-parameter syntax - Simplified capture list patterns as new onChange provides both old and new values Files fixed: - WorkspacePanelTabBar.swift - EditorTabButtonStyle.swift - EditorTabs.swift (2 instances) - ExtensionsListView.swift All onChange deprecation warnings now resolved.
1 parent 636ead0 commit 0de7f93

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

CodeEdit/Features/CodeEditUI/Views/WorkspacePanelTabBar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ struct WorkspacePanelTabBar<Tab: WorkspacePanelTab>: View {
281281
self.tabWidth[tab] = (position == .top) ? geometry.size.width : geometry.size.height
282282
self.tabLocations[tab] = geometry.frame(in: .global)
283283
}
284-
.onChange(of: geometry.frame(in: .global)) { newFrame in
284+
.onChange(of: geometry.frame(in: .global)) { _, newFrame in
285285
self.tabLocations[tab] = newFrame
286286
}
287287
.onChange(of: geometry.size.width) { _, newWidth in

CodeEdit/Features/Editor/TabBar/Tabs/Tab/EditorTabButtonStyle.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct EditorTabButtonStyle: ButtonStyle {
1919

2020
func makeBody(configuration: Configuration) -> some View {
2121
configuration.label
22-
.onChange(of: configuration.isPressed, perform: { isPressed in
22+
.onChange(of: configuration.isPressed) { _, isPressed in
2323
self.isPressing = isPressed
24-
})
24+
}
2525
}
2626
}

CodeEdit/Features/Editor/TabBar/Tabs/Views/EditorTabs.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,15 @@ struct EditorTabs: View {
223223
.frame(in: .global)
224224
}
225225
.onChange(
226-
of: tabItemGeoReader.frame(in: .global),
227-
perform: { tabCGRect in
228-
tabLocations[id] = tabCGRect
229-
}
230-
)
226+
of: tabItemGeoReader.frame(in: .global)
227+
) { _, tabCGRect in
228+
tabLocations[id] = tabCGRect
229+
}
231230
.onChange(
232-
of: tabItemGeoReader.size.width,
233-
perform: { newWidth in
234-
tabWidth[id] = newWidth
235-
}
236-
)
231+
of: tabItemGeoReader.size.width
232+
) { _, newWidth in
233+
tabWidth[id] = newWidth
234+
}
237235
}
238236
}
239237

@@ -313,7 +311,7 @@ struct EditorTabs: View {
313311
// On first tab appeared, jump to the corresponding position.
314312
scrollReader.scrollTo(editor.selectedTab)
315313
}
316-
.onChange(of: editor.tabs) { [tabs = editor.tabs] newValue in
314+
.onChange(of: editor.tabs) { tabs, newValue in
317315
if tabs.count == newValue.count {
318316
updateForTabCountChange(geometryProxy: geometryProxy)
319317
} else {

CodeEdit/Features/Extensions/ExtensionsListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct ExtensionsListView: View {
4343
.frame(width: 400, height: 300)
4444
}
4545
}
46-
.onChange(of: manager.extensions) { [oldValue = manager.extensions] newValue in
46+
.onChange(of: manager.extensions) { oldValue, newValue in
4747
// Select the first one if previously the extension list was empty.
4848
if oldValue.isEmpty, let first = newValue.first {
4949
selection = [first]

0 commit comments

Comments
 (0)