Skip to content

Commit e101b08

Browse files
mvaligurskyMartin Valigursky
and
Martin Valigursky
authored
[Fix] Preprocessor correctly updates position for text replacement (#7303)
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
1 parent 0e58330 commit e101b08

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/preprocessor.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class Preprocessor {
201201
source = source.substring(0, define.index - 1) + source.substring(DEFINE.lastIndex);
202202

203203
// continue processing on the next symbol
204-
KEYWORD.lastIndex = define.index;
204+
KEYWORD.lastIndex = define.index - 1;
205205
}
206206
}
207207

@@ -233,7 +233,7 @@ class Preprocessor {
233233
source = source.substring(0, undef.index - 1) + source.substring(UNDEF.lastIndex);
234234

235235
// continue processing on the next symbol
236-
KEYWORD.lastIndex = undef.index;
236+
KEYWORD.lastIndex = undef.index - 1;
237237
}
238238
}
239239

@@ -367,7 +367,7 @@ class Preprocessor {
367367
source = source.substring(0, include.index - 1) + includeSource + source.substring(INCLUDE.lastIndex);
368368

369369
// process the just included test
370-
KEYWORD.lastIndex = include.index;
370+
KEYWORD.lastIndex = include.index - 1;
371371
} else {
372372
console.error(`Include "${identifier}" not resolved while preprocessing ${Preprocessor.sourceName}`, { source: originalSource });
373373
error = true;

0 commit comments

Comments
 (0)