Skip to content

Commit

Permalink
github-pr-review: fix rnd position with column == 1 handling
Browse files Browse the repository at this point in the history
It actually should use the end line as-is. For example, if a suggestion
want to remove line-break, the end line actually needs to be the line
after the line-break.
  • Loading branch information
haya14busa committed Jul 25, 2020
1 parent 201045c commit 356830a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions service/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ func buildDraftReviewComment(c *reviewdog.Comment, body string) *github.DraftRev
func githubCommentLine(c *reviewdog.Comment) int {
loc := c.Result.Diagnostic.GetLocation()
line := loc.GetRange().GetEnd().GetLine()
// End position with column == 1 means range to the end of the previous lines
// including line-break.
if loc.GetRange().GetEnd().GetColumn() == 1 {
line--
}
if line == 0 {
line = loc.GetRange().GetStart().GetLine()
}
Expand Down
2 changes: 1 addition & 1 deletion service/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestGitHubPullRequest_Post_Flush_review_api(t *testing.T) {
{
Path: github.String("reviewdog.go"),
StartLine: github.Int(15),
Line: github.Int(16),
Line: github.Int(17),
Body: github.String(commentutil.BodyPrefix + "\nmultiline existing comment (line-break)"),
},
}
Expand Down

0 comments on commit 356830a

Please sign in to comment.