File tree 2 files changed +22
-6
lines changed 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -58,18 +58,20 @@ func checkCommentForPeriod(c comment) *Issue {
58
58
return nil
59
59
}
60
60
61
- // Shift position by the length of comment's special symbols: /* or //
62
- isBlock := strings .HasPrefix (c .lines [0 ], "/*" )
63
- if (isBlock && pos .line == 1 ) || ! isBlock {
64
- pos .column += 2
65
- }
61
+ // Shift position to its real value. `c.text` doesn't contain comment's
62
+ // special symbols: /* or //, and line indentations inside. It also
63
+ // contains */ in the end in case of block comment.
64
+ pos .column += strings .Index (
65
+ c .lines [pos .line - 1 ],
66
+ strings .Split (c .text , "\n " )[pos .line - 1 ],
67
+ )
66
68
67
69
iss := Issue {
68
70
Pos : token.Position {
69
71
Filename : c .start .Filename ,
70
72
Offset : c .start .Offset ,
71
73
Line : pos .line + c .start .Line - 1 ,
72
- Column : pos .column + c . start . Column - 1 ,
74
+ Column : pos .column ,
73
75
},
74
76
Message : noPeriodMessage ,
75
77
}
Original file line number Diff line number Diff line change @@ -46,6 +46,19 @@ Multiline comment with a period [PASS].
46
46
47
47
// Single-line comment with a period [PASS].
48
48
49
+ // Mixed block of comments,
50
+ /*
51
+ period must be here [PERIOD_TOP]
52
+ */
53
+
54
+ /* Mixed block of comments,
55
+ */
56
+ // period must be here [PERIOD_TOP]
57
+
58
+ /*
59
+ // Comment inside comment [PERIOD_TOP]
60
+ */
61
+
49
62
// Block comment [PERIOD_DECL]
50
63
const (
51
64
// Inside comment [PERIOD_DECL]
@@ -104,6 +117,7 @@ func CgoExportedFunction(a, b int) int {
104
117
105
118
// Кириллица [PERIOD_DECL]
106
119
func NonLatin () string {
120
+ // Тест: Mixed ASCII and non-ASCII chars.
107
121
return "привет, мир"
108
122
}
109
123
You can’t perform that action at this time.
0 commit comments