@@ -19,6 +19,20 @@ function isSandwichedMeishi({
1919 }
2020 return before . pos === "名詞" && after . pos === "名詞" ;
2121}
22+ /**
23+ * add two positions.
24+ * note: line starts with 1, column starts with 0.
25+ * @param {Position } base
26+ * @param {Position } relative
27+ * @return {Position }
28+ */
29+ function addPositions ( base , relative ) {
30+ return {
31+ line : base . line + relative . line - 1 , // line 1 + line 1 should be line 1
32+ column : relative . line == 1 ? base . column + relative . column // when the same line
33+ : relative . column // when another line
34+ } ;
35+ }
2236/**
2337 * @param {RuleContext } context
2438 * @param {object } options
@@ -78,10 +92,11 @@ export default function (context, options = {}) {
7892 }
7993 // report
8094 if ( currentTenCount >= maxLen ) {
81- let position = source . indexToPosition ( lastToken . word_position - 1 ) ;
95+ let positionInSentence = source . indexToPosition ( lastToken . word_position - 1 ) ;
96+ let positionInNode = addPositions ( sentence . loc . start , positionInSentence ) ;
8297 let ruleError = new context . RuleError ( `一つの文で"、"を${ maxLen } つ以上使用しています` , {
83- line : position . line - 1 ,
84- column : position . column
98+ line : positionInNode . line - 1 ,
99+ column : positionInNode . column
85100 } ) ;
86101 report ( node , ruleError ) ;
87102 currentTenCount = 0 ;
0 commit comments