Skip to content

Commit 7a1cc1d

Browse files
committed
fix(rule): fix reported index
1 parent 4dce092 commit 7a1cc1d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/textlint-rule-no-unmatched-pair.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const report = context => {
2626
while (source.canRead) {
2727
// If the character is in ignored range, skip it
2828
const characterIndex = sentenceIndex + source.index;
29+
// console.log(characterIndex, source.text[source.index], ignoreNodeManager.isIgnoredIndex(characterIndex));
2930
if (!ignoreNodeManager.isIgnoredIndex(characterIndex)) {
3031
pairMaker.mark(source);
3132
}
@@ -37,7 +38,7 @@ const report = context => {
3738
3839
You should close this sentence with ${contextLocation.pairMark.end}.
3940
This pair mark is called ${contextLocation.pairMark.key}.`, {
40-
index: contextLocation.index
41+
index: sentenceIndex + contextLocation.index
4142
}));
4243
});
4344
});

test/textlint-rule-no-unmatched-pair-test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ This pair mark is called double quote.`
5151
+ "モジュールは、基本的には何かしらを外部に公開(`export`)します。",
5252
errors: [
5353
{
54-
index: 23
54+
index: 74
55+
}
56+
]
57+
}, {
58+
text: `このように\`count\`変数が自動解放されずに保持できているのは「(\`increment\`)関数が外側のスコープにある(\`count\`)変数への参照を保持できる」ためです。このような性質のことをクロージャー(関数閉包)と呼びます。クロージャーは静的スコープと変数は参照され続けていればデータは保持されるという2つの性質によって成り立っています。`,
59+
errors: [
60+
{
61+
index: 104
5562
}
5663
]
5764
}

0 commit comments

Comments
 (0)