Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/cs-main' into fetch-upstream-170924
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwriternr committed Sep 18, 2024
2 parents 47fb3f4 + b4159ed commit 61d180b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions extensions/codestory/src/server/editedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface DiffAcrossDocuments {
uri: vscode.Uri;
languageId: string;
latestChangeTimestamp: number;
currentContent: string;
}

export class RecentEditsRetriever implements vscode.Disposable {
Expand Down Expand Up @@ -65,6 +66,7 @@ export class RecentEditsRetriever implements vscode.Disposable {
fs_file_path: diff.uri.fsPath,
diff: content,
updated_timestamp_ms: diff.latestChangeTimestamp,
currentContent: diff.currentContent,
};
autocompleteContextSnippets.push(autocompleteSnippet);
}
Expand Down Expand Up @@ -99,12 +101,13 @@ export class RecentEditsRetriever implements vscode.Disposable {
const diff = await this.getDiff(vscode.Uri.parse(uri));
if (diff) {
return {
diff,
diff: diff.diff,
uri: trackedDocument.uri,
languageId: trackedDocument.languageId,
latestChangeTimestamp: Math.max(
...trackedDocument.changes.map(c => c.timestamp)
),
currentContent: diff.currentContent,
};
}
return null;
Expand All @@ -129,7 +132,10 @@ export class RecentEditsRetriever implements vscode.Disposable {
return true;
}

public async getDiff(uri: vscode.Uri): Promise<string | null> {
public async getDiff(uri: vscode.Uri): Promise<{
diff: string | null;
currentContent: string | null;
} | null> {
const trackedDocument = this.trackedDocuments.get(uri.toString());
if (!trackedDocument) {
return null;
Expand All @@ -141,7 +147,11 @@ export class RecentEditsRetriever implements vscode.Disposable {
trackedDocument.changes.map(c => c.change)
);

return createGitDiff(uri.fsPath, oldContent, newContent);
const diff = createGitDiff(uri.fsPath, oldContent, newContent);
return {
diff,
currentContent: newContent,
};
}

private onDidChangeTextDocument(event: vscode.TextDocumentChangeEvent): void {
Expand Down

0 comments on commit 61d180b

Please sign in to comment.