Skip to content

Commit

Permalink
fix: the review comment should go on the old file lines, not the new …
Browse files Browse the repository at this point in the history
…file lines (#140)
  • Loading branch information
chingor13 committed Oct 9, 2020
1 parent 841526d commit 662391f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -67,20 +67,20 @@ export function buildReviewComments(
suggestions.forEach((hunks: Hunk[], fileName: string) => {
hunks.forEach(hunk => {
const newContent = hunk.newContent.join('\n');
if (hunk.newStart === hunk.newEnd) {
if (hunk.oldStart === hunk.oldEnd) {
const singleComment: SingleLineComment = {
path: fileName,
body: `\`\`\`suggestion\n${newContent}\n\`\`\``,
line: hunk.newEnd,
line: hunk.oldEnd,
side: 'RIGHT',
};
fileComments.push(singleComment);
} else {
const comment: MultilineComment = {
path: fileName,
body: `\`\`\`suggestion\n${newContent}\n\`\`\``,
start_line: hunk.newStart,
line: hunk.newEnd,
start_line: hunk.oldStart,
line: hunk.oldEnd,
side: 'RIGHT',
start_side: 'RIGHT',
};
Expand Down
2 changes: 1 addition & 1 deletion test/inline-suggest.ts
Expand Up @@ -35,7 +35,7 @@ describe('buildFileComments', () => {
oldStart: 1,
oldEnd: 2,
newStart: 1,
newEnd: 2,
newEnd: 1,
newContent: ['Foo'],
};
suggestions.set(fileName1, [hunk1]);
Expand Down

0 comments on commit 662391f

Please sign in to comment.