From de3ec24fff1459f75d5aa308c1fb3db4f86ae0fc Mon Sep 17 00:00:00 2001 From: hitesh-1997 Date: Sat, 14 Sep 2024 00:59:40 +0530 Subject: [PATCH 1/2] fix the diff for recent edits by replacing psDedent with ps --- .../context/retrievers/recent-edits/recent-edits-retriever.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6ecac940e98c..6bd1af40dcd3 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 @@ -97,7 +97,7 @@ export class RecentEditsRetriever implements vscode.Disposable, ContextRetriever 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}` + const prompt = ps`${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 } From bdef4ff9144ff4a784187333aaf9aead6e924084 Mon Sep 17 00:00:00 2001 From: hitesh-1997 Date: Sat, 14 Sep 2024 01:09:51 +0530 Subject: [PATCH 2/2] add simple diff without additional comments --- .../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 6bd1af40dcd3..09262ebb6af4 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 = ps`${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