Skip to content

Commit a6e6da0

Browse files
committed
store less context
and remove reset option, we dont need that
1 parent 5d120c0 commit a6e6da0

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

src/services/ghost/GhostInlineCompletionProvider.ts

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
import * as vscode from "vscode"
2-
import { GhostSuggestionsState } from "./GhostSuggestions"
2+
import { FillInAtCursorSuggestion, GhostSuggestionsState } from "./GhostSuggestions"
33
import { extractPrefixSuffix } from "./types"
44

55
const MAX_SUGGESTIONS_HISTORY = 20
66

77
export class GhostInlineCompletionProvider implements vscode.InlineCompletionItemProvider {
8-
private suggestionsHistory: GhostSuggestionsState[] = []
8+
private suggestionsHistory: FillInAtCursorSuggestion[] = []
99

10-
public updateSuggestions(suggestions: GhostSuggestionsState | null): void {
11-
if (suggestions == null) {
10+
public updateSuggestions(suggestions: GhostSuggestionsState): void {
11+
const fillInAtCursor = suggestions.getFillInAtCursor()
12+
13+
// Only store if we have a fill-in suggestion
14+
if (!fillInAtCursor) {
1215
return
1316
}
1417

15-
const fillInAtCursor = suggestions.getFillInAtCursor()
16-
1718
// Check if this suggestion already exists in the history
18-
if (fillInAtCursor) {
19-
const isDuplicate = this.suggestionsHistory.some((existingSuggestion) => {
20-
const existingFillIn = existingSuggestion.getFillInAtCursor()
21-
return (
22-
existingFillIn &&
23-
existingFillIn.text === fillInAtCursor.text &&
24-
existingFillIn.prefix === fillInAtCursor.prefix &&
25-
existingFillIn.suffix === fillInAtCursor.suffix
26-
)
27-
})
19+
const isDuplicate = this.suggestionsHistory.some(
20+
(existing) =>
21+
existing.text === fillInAtCursor.text &&
22+
existing.prefix === fillInAtCursor.prefix &&
23+
existing.suffix === fillInAtCursor.suffix,
24+
)
2825

29-
// Skip adding if it's a duplicate
30-
if (isDuplicate) {
31-
return
32-
}
26+
// Skip adding if it's a duplicate
27+
if (isDuplicate) {
28+
return
3329
}
3430

3531
// Add to the end of the array (most recent)
36-
this.suggestionsHistory.push(suggestions)
32+
this.suggestionsHistory.push(fillInAtCursor)
3733

3834
// Remove oldest if we exceed the limit
3935
if (this.suggestionsHistory.length > MAX_SUGGESTIONS_HISTORY) {
@@ -51,12 +47,7 @@ export class GhostInlineCompletionProvider implements vscode.InlineCompletionIte
5147

5248
// Search from most recent to least recent
5349
for (let i = this.suggestionsHistory.length - 1; i >= 0; i--) {
54-
const suggestions = this.suggestionsHistory[i]
55-
const fillInAtCursor = suggestions?.getFillInAtCursor()
56-
57-
if (!fillInAtCursor) {
58-
continue
59-
}
50+
const fillInAtCursor = this.suggestionsHistory[i]
6051

6152
// First, try exact prefix/suffix match
6253
if (prefix === fillInAtCursor.prefix && suffix === fillInAtCursor.suffix) {

src/services/ghost/GhostProvider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ export class GhostProvider {
434434
TelemetryService.instance.captureEvent(TelemetryEventName.INLINE_ASSIST_REJECT_SUGGESTION, {
435435
taskId: this.taskId,
436436
})
437-
this.inlineCompletionProvider.updateSuggestions(null)
438437
this.suggestions.clear()
439438

440439
this.clearAutoTriggerTimer()

0 commit comments

Comments
 (0)