Fix: cache metaIndex

This commit is contained in:
eight 2018-09-01 21:34:44 +08:00
parent e3316aa811
commit d335c87601

View File

@ -4,6 +4,7 @@
function createMetaCompiler(cm) { function createMetaCompiler(cm) {
const successCallbacks = []; const successCallbacks = [];
let meta = null; let meta = null;
let metaIndex = null;
let cache = []; let cache = [];
linter.register((text, options, _cm) => { linter.register((text, options, _cm) => {
@ -14,7 +15,7 @@ function createMetaCompiler(cm) {
if (!match) { if (!match) {
return []; return [];
} }
if (match[0] === meta) { if (match[0] === meta && match.index === metaIndex) {
return cache; return cache;
} }
return parseMeta(match[0]) return parseMeta(match[0])
@ -23,10 +24,12 @@ function createMetaCompiler(cm) {
cb(result); cb(result);
} }
meta = match[0]; meta = match[0];
metaIndex = match.index;
cache = []; cache = [];
return cache; return cache;
}, err => { }, err => {
meta = match[0]; meta = match[0];
metaIndex = match.index;
cache = [{ cache = [{
from: cm.posFromIndex((err.index || 0) + match.index), from: cm.posFromIndex((err.index || 0) + match.index),
to: cm.posFromIndex((err.index || 0) + match.index), to: cm.posFromIndex((err.index || 0) + match.index),