You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The clone() function on StateStack doesn't actually clone the object, but instead just returns the original object (reference)
meaning, tokenizeLine() will still modify the ruleStack that I was given
This is intentional and is a technique to save memory.
The _enterPos and _anchorPos fields are used for temporary storage and they only make sense during tokenization of a line. No external user of the library should make any assumption about those two fields. Then, clone() returns this because all other fields are immutable. This is to save memory.
The
clone()
function onStateStack
doesn't actually clone the object, but instead just returns the original object (reference)meaning,
tokenizeLine()
will still modify theruleStack
that I was givenvscode-textmate/src/main.ts
Line 262 in 09effd8
Problem is that the clone implementation doesn't actually do any cloning
vscode-textmate/src/grammar/grammar.ts
Lines 732 to 734 in 09effd8
instead something like
structuredClone()
should be used or use the clone function provided in theutils.ts
filevscode-textmate/src/utils.ts
Lines 7 to 9 in 09effd8
Found this out when the
_enterPos
and_anchorPos
kept getting modified externallyThe text was updated successfully, but these errors were encountered: