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

fix the diff for recent edits by replacing psDedent with ps #5574

Merged
merged 2 commits into from
Sep 13, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { PromptString, contextFiltersProvider } from '@sourcegraph/cody-shared'
import { ps, psDedent } from '@sourcegraph/cody-shared'
import type { AutocompleteContextSnippet } from '@sourcegraph/cody-shared'
import * as vscode from 'vscode'
import { getLanguageConfig } from '../../../../tree-sitter/language'
import type { ContextRetriever, ContextRetrieverOptions } from '../../../types'
import { RetrieverIdentifier, type ShouldUseContextParams, shouldBeUsedAsContext } from '../../utils'

Expand Down Expand Up @@ -47,11 +45,7 @@ export class RecentEditsRetriever implements vscode.Disposable, ContextRetriever

const autocompleteContextSnippets = []
for (const diff of diffs) {
const content = this.getCommentedPromptForCompletions(
diff.languageId,
diff.uri,
diff.diff
).toString()
const content = diff.diff.toString()
const autocompleteSnippet = {
uri: diff.uri,
identifier: RetrieverIdentifier.RecentEditsRetriever,
Expand Down Expand Up @@ -89,18 +83,6 @@ export class RecentEditsRetriever implements vscode.Disposable, ContextRetriever
return diffs
}

public getCommentedPromptForCompletions(
languageId: string,
filename: vscode.Uri,
diff: PromptString
): PromptString {
const filePath = PromptString.fromDisplayPath(filename)
const languageConfig = getLanguageConfig(languageId)
const commentStart = languageConfig ? languageConfig.commentStart : ps`// `
const prompt = psDedent`${commentStart} Here is git diff of the recent change made to the file ${filePath} which is used to provide context for the completion:\n${diff}`
return prompt
}

public filterCandidateDiffs(
allDiffs: DiffAcrossDocuments[],
document: vscode.TextDocument
Expand Down
Loading