From 010fa9cfd8e28e1c75c99049d0fc5efcdf4bd4d3 Mon Sep 17 00:00:00 2001 From: Martin Valigursky Date: Mon, 20 Jan 2025 16:41:30 +0000 Subject: [PATCH] [Fix] Preprocessor correctly updates position for text replacement --- src/core/preprocessor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/preprocessor.js b/src/core/preprocessor.js index 724e66d8e6c..9c34bb97921 100644 --- a/src/core/preprocessor.js +++ b/src/core/preprocessor.js @@ -201,7 +201,7 @@ class Preprocessor { source = source.substring(0, define.index - 1) + source.substring(DEFINE.lastIndex); // continue processing on the next symbol - KEYWORD.lastIndex = define.index; + KEYWORD.lastIndex = define.index - 1; } } @@ -233,7 +233,7 @@ class Preprocessor { source = source.substring(0, undef.index - 1) + source.substring(UNDEF.lastIndex); // continue processing on the next symbol - KEYWORD.lastIndex = undef.index; + KEYWORD.lastIndex = undef.index - 1; } } @@ -367,7 +367,7 @@ class Preprocessor { source = source.substring(0, include.index - 1) + includeSource + source.substring(INCLUDE.lastIndex); // process the just included test - KEYWORD.lastIndex = include.index; + KEYWORD.lastIndex = include.index - 1; } else { console.error(`Include "${identifier}" not resolved while preprocessing ${Preprocessor.sourceName}`, { source: originalSource }); error = true;