Skip to content

Commit 67bfe54

Browse files
committed
Add presentingSuggestion to Filespace
So we don't have to check index bounds everywhere
1 parent 5fd6f76 commit 67bfe54

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Core/Sources/Service/Workspace.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ final class Filespace {
1919
var suggestionIndex: Int = 0
2020
var currentSuggestionLineRange: ClosedRange<Int>?
2121
var suggestionSourceSnapshot: Snapshot = .init(linesHash: -1, cursorPosition: .outOfScope)
22+
var presentingSuggestion: CopilotCompletion? {
23+
guard suggestions.endIndex > suggestionIndex, suggestionIndex >= 0 else { return nil }
24+
return suggestions[suggestionIndex]
25+
}
2226

2327
private(set) var lastSuggestionUpdateTime: Date = Environment.now()
2428
var isExpired: Bool {

0 commit comments

Comments
 (0)