Skip to content

Commit

Permalink
fix: do not add file to prompt if only removed lines (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
gowoons authored Aug 14, 2023
1 parent 80ee5b2 commit a33f49a
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,18 @@ export const createPromptFiles = (
maxPromptPayloadLength: number,
maxSurroundingLines?: number
): PromptFile[] => {
return files.map((file) => {
return files.reduce((result: PromptFile[], file) => {
const contentLines = file.fileContent.split("\n");
const changedLinesArray = file.changedLines.split("\n");

// Get the changed indices, total length, and min/max indices
const { changedIndices, totalChangedLinesLength, minIndex, maxIndex } =
getChangedIndicesAndLength(contentLines, changedLinesArray);

if (totalChangedLinesLength == 0) {
return result;
}

// Calculate remaining space and start/end positions
let remainingSpace =
maxPromptPayloadLength - totalChangedLinesLength - file.fileName.length;
Expand All @@ -145,9 +149,10 @@ export const createPromptFiles = (
contentLines
);

return {
result.push({
fileName: file.fileName,
promptContent: promptContent,
};
});
});
return result;
}, []);
};

0 comments on commit a33f49a

Please sign in to comment.