Skip to content

Commit a963c39

Browse files
committed
Make CodeBlock default to use LazyVStack
1 parent 6c947e1 commit a963c39

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

Core/Sources/SuggestionWidget/SuggestionPanelContent/CodeBlock.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ struct CodeBlock: View {
88
let commonPrecedingSpaceCount: Int
99
let highlightedCode: [NSAttributedString]
1010
let firstLinePrecedingSpaceCount: Int
11+
12+
@AppStorage(\.disableLazyVStack) var disableLazyVStack
1113

1214
init(
1315
code: String,
@@ -32,9 +34,22 @@ struct CodeBlock: View {
3234
commonPrecedingSpaceCount = result.commonLeadingSpaceCount
3335
highlightedCode = result.code
3436
}
37+
38+
@ViewBuilder
39+
func vstack(@ViewBuilder content: () -> some View) -> some View {
40+
if disableLazyVStack {
41+
VStack(spacing: 4) {
42+
content()
43+
}
44+
} else {
45+
LazyVStack(spacing: 4) {
46+
content()
47+
}
48+
}
49+
}
3550

3651
var body: some View {
37-
VStack(spacing: 4) {
52+
vstack {
3853
ForEach(0..<highlightedCode.endIndex, id: \.self) { index in
3954
HStack(alignment: .firstTextBaseline, spacing: 4) {
4055
Text("\(index + startLineIndex + 1)")

0 commit comments

Comments
 (0)