Skip to content

Commit 75e259a

Browse files
committed
Display column number in suggestion panel
1 parent b366666 commit 75e259a

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

Core/Sources/Service/GUI/WidgetDataSource.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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

Core/Sources/SuggestionWidget/SuggestionPanelContent/CodeBlockSuggestionPanel.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff 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

172181
struct 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];

Core/Sources/SuggestionWidget/SuggestionProvider.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)