From 29b3a607671116e33491b8ec2c3a2b94a341f5c7 Mon Sep 17 00:00:00 2001 From: Hitesh Sagtani Date: Sat, 14 Sep 2024 01:53:32 +0530 Subject: [PATCH] fix the diff for recent edits by replacing psDedent with ps (#5574) ## Context `psDedent` removed the spaces making diff invalid. Replaced with `ps` ## Test plan 1. Manual testing by checking the diff validity --- .../recent-edits/recent-edits-retriever.ts | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/vscode/src/completions/context/retrievers/recent-edits/recent-edits-retriever.ts b/vscode/src/completions/context/retrievers/recent-edits/recent-edits-retriever.ts index de1fdedb9dc9..b7d8a8e695d5 100644 --- a/vscode/src/completions/context/retrievers/recent-edits/recent-edits-retriever.ts +++ b/vscode/src/completions/context/retrievers/recent-edits/recent-edits-retriever.ts @@ -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' @@ -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, @@ -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