vscode-textmate
vscode-textmate copied to clipboard
`ruleStack.clone()` doesn't actually clone
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
https://github.com/microsoft/vscode-textmate/blob/09effd8b7429b71010e0fa34ea2e16e622692946/src/main.ts#L262
Problem is that the clone implementation doesn't actually do any cloning
https://github.com/microsoft/vscode-textmate/blob/09effd8b7429b71010e0fa34ea2e16e622692946/src/grammar/grammar.ts#L732-L734
instead something like structuredClone()
should be used or use the clone function provided in the utils.ts
file
https://github.com/microsoft/vscode-textmate/blob/09effd8b7429b71010e0fa34ea2e16e622692946/src/utils.ts#L7-L9
Found this out when the _enterPos
and _anchorPos
kept getting modified externally