@@ -1879,7 +1879,7 @@ local function doLateExpansionsResources(tokensToExpand, fileBuffers, params, st
18791879 local tokNext , iNext = getNextUsableToken (tokenStack , # tokenStack - 1 , nil , - 1 )
18801880
18811881 -- @insert "name"
1882- if ppKeywordTok .value == " insert" and isTokenAndNotNil (tokNext , " string" ) then
1882+ if ppKeywordTok .value == " insert" and isTokenAndNotNil (tokNext , " string" ) and tokNext . file == ppKeywordTok . file then
18831883 local nameTok = tokNext
18841884 popTokens (tokenStack , iNext ) -- the string
18851885
@@ -1936,7 +1936,7 @@ local function doLateExpansionsResources(tokensToExpand, fileBuffers, params, st
19361936 -- @insert identifier ( argument1, ... )
19371937 -- @insert identifier " ... "
19381938 -- @insert identifier { ... }
1939- elseif ppKeywordTok .value == " insert" and isTokenAndNotNil (tokNext , " identifier" ) then
1939+ elseif ppKeywordTok .value == " insert" and isTokenAndNotNil (tokNext , " identifier" ) and tokNext . file == ppKeywordTok . file then
19401940 local identTok = tokNext
19411941 tokNext , iNext = getNextUsableToken (tokenStack , iNext - 1 , nil , - 1 )
19421942
@@ -2034,6 +2034,7 @@ local function processPreprocessorBlockInMacroArgument(tokens, fileBuffers, toke
20342034end
20352035
20362036local function expandMacro (tokens , fileBuffers , tokenStack , macroStartTok , isNested )
2037+ -- @Robustness: Make sure key tokens came from the same source file.
20372038 local tokNext , iNext = getNextUsableToken (tokenStack , # tokenStack - 1 , nil , - 1 )
20382039
20392040 if not isTokenAndNotNil (tokNext , " identifier" ) then
0 commit comments