Skip to content

Commit

Permalink
[Fix] Preprocessor correctly updates position for text replacement (#…
Browse files Browse the repository at this point in the history
…7303)

Co-authored-by: Martin Valigursky <[email protected]>
  • Loading branch information
mvaligursky and Martin Valigursky committed Jan 20, 2025
1 parent 1c2d49f commit a41f6e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,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;
}
}

Expand Down Expand Up @@ -228,7 +228,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;
}
}

Expand Down Expand Up @@ -362,7 +362,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 a shader`, { source: originalSource });
error = true;
Expand Down

0 comments on commit a41f6e7

Please sign in to comment.