Skip to content

Commit

Permalink
Merge pull request #36 from etilite/fix-check-capital
Browse files Browse the repository at this point in the history
fix: panic due incorrect issue's position column resolution in checkCapital
  • Loading branch information
tetafro authored Sep 7, 2024
2 parents 37dcdfb + 4e04496 commit 348de9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func checkCapital(c comment) []Issue {
if state == endOfSentence && unicode.IsLower(r) {
pp = append(pp, position{
line: pos.line,
column: runeToByteColumn(c.text, pos.column),
column: runeToByteColumn(c.lines[pos.line-1], pos.column),
})
}
state = empty
Expand Down
11 changes: 11 additions & 0 deletions checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,17 @@ func TestCheckCapital(t *testing.T) {
{Pos: token.Position{Line: 1, Column: 23}},
},
},
{
name: "issue position column resolved from correct line",
comment: comment{
lines: []string{"// Кириллица.", "// Issue. here."},
text: " Кириллица.\n Issue. here.",
start: start,
},
issues: []Issue{
{Pos: token.Position{Line: 2, Column: 11}},
},
},
{
name: "sentence with leading spaces",
comment: comment{
Expand Down

0 comments on commit 348de9f

Please sign in to comment.