forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuggestionProvider.swift
More file actions
43 lines (39 loc) · 1.79 KB
/
SuggestionProvider.swift
File metadata and controls
43 lines (39 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Foundation
import SwiftUI
public final class SuggestionProvider: ObservableObject {
@Published public var code: String = ""
@Published public var language: String = ""
@Published public var startLineIndex: Int = 0
@Published public var suggestionCount: Int = 0
@Published public var currentSuggestionIndex: Int = 0
@Published public var commonPrecedingSpaceCount = 0
public var onSelectPreviousSuggestionTapped: () -> Void
public var onSelectNextSuggestionTapped: () -> Void
public var onRejectSuggestionTapped: () -> Void
public var onAcceptSuggestionTapped: () -> Void
public init(
code: String = "",
language: String = "",
startLineIndex: Int = 0,
suggestionCount: Int = 0,
currentSuggestionIndex: Int = 0,
onSelectPreviousSuggestionTapped: @escaping () -> Void = {},
onSelectNextSuggestionTapped: @escaping () -> Void = {},
onRejectSuggestionTapped: @escaping () -> Void = {},
onAcceptSuggestionTapped: @escaping () -> Void = {}
) {
self.code = code
self.language = language
self.startLineIndex = startLineIndex
self.suggestionCount = suggestionCount
self.currentSuggestionIndex = currentSuggestionIndex
self.onSelectPreviousSuggestionTapped = onSelectPreviousSuggestionTapped
self.onSelectNextSuggestionTapped = onSelectNextSuggestionTapped
self.onRejectSuggestionTapped = onRejectSuggestionTapped
self.onAcceptSuggestionTapped = onAcceptSuggestionTapped
}
func selectPreviousSuggestion() { onSelectPreviousSuggestionTapped() }
func selectNextSuggestion() { onSelectNextSuggestionTapped() }
func rejectSuggestion() { onRejectSuggestionTapped() }
func acceptSuggestion() { onAcceptSuggestionTapped() }
}