macos: use TextEditor instead of Text for clipboard confirmation (#9324)

Fixes #9322

SwiftUI `Text` has huge performance issues. On my maxed out MBP it hangs
for any text more than 100KB (it took ~8s to display it!). `TextEditor`
with a constant value works much better and handles scrolling for us,
too!
This commit is contained in:
Mitchell Hashimoto
2025-10-23 09:22:35 -07:00
parent b9df743e04
commit 28952a7bb0

View File

@@ -45,19 +45,15 @@ struct ClipboardConfirmationView: View {
.font(.system(size: 42))
.padding()
.frame(alignment: .center)
Text(request.text())
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
}
ScrollView {
Text(contents)
.textSelection(.enabled)
.font(.system(.body, design: .monospaced))
.padding(.all, 4)
}
TextEditor(text: .constant(contents))
.font(.system(.body, design: .monospaced))
HStack {
Spacer()
Button(Action.text(.cancel, request)) { onCancel() }