Commit 872e2e07ad

872e2e07ad2d2b93c62c6cd3589355b6b44b81ed

parent: 23880331ce

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-30 04:32 UTC

Snippet view: one Text per line

A single Text of a long snippet file does not draw. Split with codeLines,
as the file view does.

Layout: unified · split

gitbay/Views/Snippets/SnippetView.swift +9 −3
@@ -200,16 +200,22 @@ struct SnippetView: View {
200 } 200 }
201 } 201 }
202 202
203 /// One Text per line: a single Text of a long file does not draw.
203 private func code(_ file: SnippetFile) -> some View { 204 private func code(_ file: SnippetFile) -> some View {
204 let text = file.content ?? "" 205 let text = file.content ?? ""
205 let size = UIFont.preferredFont(forTextStyle: .caption1).pointSize 206 let size = UIFont.preferredFont(forTextStyle: .caption1).pointSize
206 let font = UIFont(name: "Atkinson Hyperlegible Mono", size: size) 207 let font = UIFont(name: "Atkinson Hyperlegible Mono", size: size)
207 ?? .monospacedSystemFont(ofSize: size, weight: .regular) 208 ?? .monospacedSystemFont(ofSize: size, weight: .regular)
208 let highlighter = SyntaxHighlighter(colorScheme: colorScheme) 209 let highlighter = SyntaxHighlighter(colorScheme: colorScheme)
209 if let highlighted = highlighter.highlight(text, fileName: file.name, font: font) { 210 let lines = codeLines(highlighter.highlight(text, fileName: file.name, font: font)
210 return Text(AttributedString(highlighted)) 211 ?? NSAttributedString(string: text))
212 return VStack(alignment: .leading, spacing: 0) {
213 ForEach(lines.indices, id: \.self) { index in
214 Text(lines[index].characters.isEmpty ? " " : lines[index])
215 .fixedSize()
216 }
211 } 217 }
212 return Text(text).font(.gbMono(.caption)) 218 .font(.gbMono(.caption))
213 } 219 }
214} 220}
215 221