Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the current document to track range for persistence #5812

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions vscode/src/completions/inline-completion-item-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,6 @@ export class InlineCompletionItemProvider
suggestionEvent.markAsRead({
document: invokedDocument,
position: invokedPosition,
completePrefix: completion.requestParams.docContext.completePrefix,
completeSuffix: completion.requestParams.docContext.completeSuffix,
})
}
}, this.COMPLETION_VISIBLE_DELAY_MS)
Expand Down
8 changes: 0 additions & 8 deletions vscode/src/completions/logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ describe('logger', () => {
suggestionEvent?.markAsRead({
document,
position,
completePrefix: defaultRequestParams.docContext.completePrefix,
completeSuffix: defaultRequestParams.docContext.completeSuffix,
})
CompletionLogger.accepted(id, document, item, range(0, 0, 0, 0), false)

Expand Down Expand Up @@ -119,8 +117,6 @@ describe('logger', () => {
firstSuggestionEvent?.markAsRead({
document,
position,
completePrefix: defaultRequestParams.docContext.completePrefix,
completeSuffix: defaultRequestParams.docContext.completeSuffix,
})

const loggerItem = CompletionLogger.getCompletionEvent(id1)
Expand All @@ -142,8 +138,6 @@ describe('logger', () => {
secondSuggestionEvent?.markAsRead({
document,
position,
completePrefix: defaultRequestParams.docContext.completePrefix,
completeSuffix: defaultRequestParams.docContext.completeSuffix,
})
CompletionLogger.accepted(id2, document, item, range(0, 0, 0, 0), false)

Expand Down Expand Up @@ -172,8 +166,6 @@ describe('logger', () => {
thirdSuggestionEvent?.markAsRead({
document,
position,
completePrefix: defaultRequestParams.docContext.completePrefix,
completeSuffix: defaultRequestParams.docContext.completeSuffix,
})

const loggerItem3 = CompletionLogger.getCompletionEvent(id3)
Expand Down
20 changes: 5 additions & 15 deletions vscode/src/completions/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,7 @@ function getInlineContextItemContext(
function suggestionDocumentDiffTracker(
interactionId: CompletionAnalyticsID,
document: vscode.TextDocument,
position: vscode.Position,
completePrefix: string,
completeSuffix: string
position: vscode.Position
): void {
// If user is not in the same document, we don't track the diff.
if (document.uri.scheme !== 'file') {
Expand All @@ -795,12 +793,12 @@ function suggestionDocumentDiffTracker(
Math.min(document.getText().length, document.offsetAt(position) + offsetBytes)
)
const trackingRange = new vscode.Range(startPosition, endPosition)
const documentText = completePrefix.slice(-offsetBytes) + completeSuffix.slice(0, offsetBytes)
const documentText = document.getText(trackingRange)

const persistenceTimeoutList = [
15 * 1000, // 15 seconds
30 * 1000, // 30 seconds
20 * 1000, // 20 seconds
60 * 1000, // 60 seconds
120 * 1000, // 120 seconds
]
persistenceTracker.track({
id: interactionId,
Expand All @@ -820,8 +818,6 @@ function suggestionDocumentDiffTracker(
type SuggestionMarkReadParam = {
document: vscode.TextDocument
position: vscode.Position
completePrefix: string
completeSuffix: string
}

// Suggested completions will not be logged immediately. Instead, we log them when we either hide
Expand Down Expand Up @@ -879,13 +875,7 @@ export function prepareSuggestionEvent({
isDotCom(authStatus.endpoint || '') &&
event.params.inlineCompletionItemContext?.isRepoPublic
) {
suggestionDocumentDiffTracker(
event.params.id,
param.document,
param.position,
param.completePrefix,
param.completeSuffix
)
suggestionDocumentDiffTracker(event.params.id, param.document, param.position)
}
},
}
Expand Down
Loading