From 83a1ae826745ab2e3e8e9178b6ae962f42344b9d Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Sat, 29 Jun 2024 11:17:33 +0900 Subject: [PATCH] Make .onGeometryChange one line --- CotEditor/Sources/CharacterCountOptionsView.swift | 4 +--- CotEditor/Sources/SyntaxEditView.swift | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CotEditor/Sources/CharacterCountOptionsView.swift b/CotEditor/Sources/CharacterCountOptionsView.swift index 8374c6aa4..a276edb18 100644 --- a/CotEditor/Sources/CharacterCountOptionsView.swift +++ b/CotEditor/Sources/CharacterCountOptionsView.swift @@ -107,9 +107,7 @@ struct CharacterCountOptionsView: View { } } .fixedSize() - .onGeometryChange(for: CGFloat.self, of: \.size.width) { newWidth in - self.contentWidth = newWidth - } + .onGeometryChange(for: CGFloat.self, of: \.size.width) { self.contentWidth = $0 } } if self.unit != .graphemeCluster { diff --git a/CotEditor/Sources/SyntaxEditView.swift b/CotEditor/Sources/SyntaxEditView.swift index fe3882fb1..26bcbce92 100644 --- a/CotEditor/Sources/SyntaxEditView.swift +++ b/CotEditor/Sources/SyntaxEditView.swift @@ -178,10 +178,7 @@ struct SyntaxEditView: View { self.errors = self.syntax.validate() } .alert(error: $error) - .onGeometryChange(for: CGSize.self, of: \.size) { newValue in - // store last view size - Self.viewSize = newValue - } + .onGeometryChange(for: CGSize.self, of: \.size) { Self.viewSize = $0 } .frame(idealWidth: Self.viewSize.width, minHeight: 525, idealHeight: Self.viewSize.height) }