File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ final class WidgetDataSource {
1818 if useGlobalChat {
1919 chat = globalChat ?? ChatService ( chatGPTService: ChatGPTService ( ) )
2020 globalChat = chat
21-
2221 } else {
2322 chat = chats [ url] ?? ChatService ( chatGPTService: ChatGPTService ( ) )
2423 chats [ url] = chat
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ struct CodeBlock: View {
55 @Environment ( \. colorScheme) var colorScheme
66
77 var body : some View {
8- VStack {
8+ VStack ( spacing : 4 ) {
99 let code = suggestion. highlightedCode ( colorScheme: colorScheme)
1010 ForEach ( 0 ..< code. endIndex, id: \. self) { index in
1111 HStack ( alignment: . firstTextBaseline) {
@@ -18,6 +18,15 @@ struct CodeBlock: View {
1818 . frame ( maxWidth: . infinity, alignment: . leading)
1919 . multilineTextAlignment ( . leading)
2020 . lineSpacing ( 4 )
21+ . overlay ( alignment: . topLeading) {
22+ if index == 0 {
23+ Text ( " \( suggestion. commonPrecedingSpaceCount + 1 ) " )
24+ . padding ( . top, - 12 )
25+ . font ( . footnote)
26+ . foregroundStyle ( colorScheme == . dark ? . white : . black)
27+ . opacity ( 0.3 )
28+ }
29+ }
2130 }
2231 }
2332 }
@@ -171,7 +180,7 @@ struct CodeBlockSuggestionPanel_Dark_Objc_Preview: PreviewProvider {
171180
172181struct CodeBlockSuggestionPanel_Bright_Objc_Preview : PreviewProvider {
173182 static var previews : some View {
174- CodeBlockSuggestionPanel ( suggestion: SuggestionProvider (
183+ CodeBlockSuggestionPanel ( suggestion: SuggestionProvider (
175184 code: """
176185 - (void)addSubview:(UIView *)view {
177186 [self addSubview:view];
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ public final class SuggestionProvider: ObservableObject {
2727 droppingLeadingSpaces: true
2828 )
2929 highlightedCode = new
30- commonPrecedingSpaceCount = spaceCount
30+ Task { @MainActor in
31+ commonPrecedingSpaceCount = spaceCount
32+ }
3133 return new
3234 }
3335
You can’t perform that action at this time.
0 commit comments