Skip to content

Commit 348de9f

Browse files
authored
Merge pull request #36 from etilite/fix-check-capital
fix: panic due incorrect issue's position column resolution in checkCapital
2 parents 37dcdfb + 4e04496 commit 348de9f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

checks.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func checkCapital(c comment) []Issue {
171171
if state == endOfSentence && unicode.IsLower(r) {
172172
pp = append(pp, position{
173173
line: pos.line,
174-
column: runeToByteColumn(c.text, pos.column),
174+
column: runeToByteColumn(c.lines[pos.line-1], pos.column),
175175
})
176176
}
177177
state = empty

checks_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ func TestCheckCapital(t *testing.T) {
337337
{Pos: token.Position{Line: 1, Column: 23}},
338338
},
339339
},
340+
{
341+
name: "issue position column resolved from correct line",
342+
comment: comment{
343+
lines: []string{"// Кириллица.", "// Issue. here."},
344+
text: " Кириллица.\n Issue. here.",
345+
start: start,
346+
},
347+
issues: []Issue{
348+
{Pos: token.Position{Line: 2, Column: 11}},
349+
},
350+
},
340351
{
341352
name: "sentence with leading spaces",
342353
comment: comment{

0 commit comments

Comments
 (0)