Skip to content

Commit a41f6e7

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

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
@@ -196,7 +196,7 @@ class Preprocessor {
196196
source = source.substring(0, define.index - 1) + source.substring(DEFINE.lastIndex);
197197

198198
// continue processing on the next symbol
199-
KEYWORD.lastIndex = define.index;
199+
KEYWORD.lastIndex = define.index - 1;
200200
}
201201
}
202202

@@ -228,7 +228,7 @@ class Preprocessor {
228228
source = source.substring(0, undef.index - 1) + source.substring(UNDEF.lastIndex);
229229

230230
// continue processing on the next symbol
231-
KEYWORD.lastIndex = undef.index;
231+
KEYWORD.lastIndex = undef.index - 1;
232232
}
233233
}
234234

@@ -362,7 +362,7 @@ class Preprocessor {
362362
source = source.substring(0, include.index - 1) + includeSource + source.substring(INCLUDE.lastIndex);
363363

364364
// process the just included test
365-
KEYWORD.lastIndex = include.index;
365+
KEYWORD.lastIndex = include.index - 1;
366366
} else {
367367
console.error(`Include "${identifier}" not resolved while preprocessing a shader`, { source: originalSource });
368368
error = true;

0 commit comments

Comments
 (0)