Skip to content

Fix rule registry mutability issue with multiple language keys - #87

Merged
JohannesMeierSE merged 1 commit into
TypeFox:mainfrom
domu1de:fix-rule-registry-languagekeys
Jul 24, 2025
Merged

Fix rule registry mutability issue with multiple language keys#87
JohannesMeierSE merged 1 commit into
TypeFox:mainfrom
domu1de:fix-rule-registry-languagekeys

Conversation

@domu1de

@domu1de domu1de commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

When registering rules with a languageKey array, the rule registry was storing the original array by reference. This led to issues when removeRule modified the array in place.

This behavior caused problems in contexts where rules are removed and re-registered during initialization — such as in classes or functions — because the original languageKey array had already been altered.

This PR resolves the issue by creating a shallow copy of the languageKey array during rule registration to ensure immutability and prevent side effects during rule lifecycle operations.

@JohannesMeierSE JohannesMeierSE left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix!

Feel free to create even more PRs, if you find further issues!

@JohannesMeierSE JohannesMeierSE added the bug Something isn't working label Jul 24, 2025
@JohannesMeierSE JohannesMeierSE modified the milestones: v0.4, v0.3 Jul 24, 2025
@JohannesMeierSE
JohannesMeierSE merged commit e092981 into TypeFox:main Jul 24, 2025
1 check passed
JohannesMeierSE pushed a commit that referenced this pull request Aug 1, 2025
When registering rules with a `languageKey` array, the rule registry was storing the original array by reference. This led to issues when `removeRule` modified the array in place.

This behavior caused problems in contexts where rules are removed and re-registered during initialization — such as in classes or functions —because the original `languageKey` array had already been altered.

This PR resolves the issue by creating a shallow copy of the `languageKey` array during rule registration to ensure immutability and prevent side effects during rule lifecycle operations.
@JohannesMeierSE

Copy link
Copy Markdown
Collaborator

@domu1de We just released this bugfix with the new v0.2.2!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants