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
Problem is that the clone implementation doesn't actually do any cloning
|
public clone(): StateStackImpl { |
|
return this; |
|
} |
instead something like
structuredClone() should be used or use the clone function provided in the
utils.ts file
|
export function clone<T>(something: T): T { |
|
return doClone(something); |
|
} |
Found this out when the _enterPos and _anchorPos kept getting modified externally
The
clone()function onStateStackdoesn't actually clone the object, but instead just returns the original object (reference)meaning,
tokenizeLine()will still modify theruleStackthat 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.tsfilevscode-textmate/src/utils.ts
Lines 7 to 9 in 09effd8
Found this out when the
_enterPosand_anchorPoskept getting modified externally