feat: ability to auto-update the language definitions on settings change - #53
Merged
yCodeTech merged 5 commits intoAug 26, 2026
Merged
Conversation
…change - Added new `updateLanguageDefinitions` function in Configuration class to update the language definitions. - Refactored the `onDidChangeConfiguration` event in the `activate` function of the extension to auto-update the language definitions and reconfigure the comment blocks when a user changes the settings. It uses the new `updateLanguageDefinitions` function to update the definitions before reconfiguring the comment blocks. - Removed the old `reloadRequiredSettings` array and the `showReloadMessage` function.
- Added new Configuration class properties:
- `defaultMultiLineConfig` to store the default multi-line configuration object.
- `languagesToSkip` to store the languages to skip object.
- Refactored `getLanguagesToSkip` method to get the languages from the new `languagesToSkip` class property instead of repeatedly reading the `skip-languages.jsonc` file from disk on every loop iteration of the `findAllLanguageConfigFilePaths` method.
- Refactored `setLanguageConfiguration` method to get the default config from the new `defaultMultiLineConfig` class property instead of repeatedly reading the `default-multi-line-config.json` file from disk on every loop iteration of the `configureCommentBlocks` method.
- Added a once-per-activation disk read of the `default-multi-line-config.json` and `skip-languages.jsonc` files in the Configuration `constructor` method, and add their contents to the respective new properties. This caches the JSON objects in memory ready for later use, enhancing performance by not reading them from disk on every loop iteration.
Writing to the auto generated language definition files is not very useful in production and are only helpful in development. In production, they are only ever read from disk to log their data for debugging.
So for performance, they should only be written when in development/testing mode, and the updated definitions should only be cached in memory in production mode.
- Removed the `writeCommentLanguageDefinitionsToJsonFile` method calls from the `constructor` and `updateLanguageDefinitions` methods.
- Refactored `writeCommentLanguageDefinitionsToJsonFile` method:
- Changed the visibility of the method from `private` to `public`, so it can be called from outside of the class.
- Extracted the call to the `convertMapToReversedObject` utils function into a new method: `getSingleLineLanguageDefinitions`. This method returns the formatted and reversed single-line definitions object ready for logging or writing to JSON file.
- Extracted the `Object.fromEntries` call into a new method: `getMultiLineLanguageDefinitions`. This method returns the formatted multi-line definitions object ready for logging or writing to JSON file.
- Changed the `writeJsonFile` method calls to get the data from the 2 new methods instead of the old removed variables.
- Changed the logging of the language definitions in `logDebugInfo` method to get the data from the new `getMultiLineLanguageDefinitions` and `getSingleLineLanguageDefinitions` methods, instead of reading directly from disk.
- Added a conditional in the `activate` function to only run the `writeCommentLanguageDefinitionsToJsonFile` Configuration method when the context of the extension is not running in production (ie. it's running in development or testing mode).
The same conditional is added into the configuration change event so when the definitions auto update they are written to the files in development/testing mode.
This helps vscode to show intellisense on native JS functions.
…rride. While adding a multi-line override in the `overrideDefaultLanguageMultiLineComments` setting auto-updated the language definitions correctly and used the override style, removing the override didn't work and it was still in place internally in vscode, and the extension's auto-complete no-longer worked. This happened because the override was inadvertently changing the multi-line style in the cached internal language config whilst also changing it on the shallow-copy for the immediate setting into vscode. So without ever changing it back as it was never supposed to be changed, the override was still apart of the extension's cached language configs making it permanent and breaking functionality. - Fixed by deep-cloning the `internalLangConfig` using JavaScript's `structuredClone` function in `setLanguageConfiguration` method so mutations (like comment overrides) never write back into the cached `languageConfigs` Map, which prevents pollution during definition auto-updates. - Added deep-cloning of the comments object in the cached `defaultMultiLineConfig` using `structuredClone` to prevent shared references and accidental mutations down the line during the fallback assignment. - Update comment override assignment to construct a new block comment tuple while preserving the ending, instead of mutating the existing array in place.
yCodeTech
deleted the
feat/auto-update-language-definitions-on-settings-change
branch
August 26, 2026 06:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements to how language comment block definitions are managed and updated in the extension. The most significant changes are the ability to auto update language definitions on settings change without requiring an extension host reload, the caching of configuration files for efficiency, and performance improvements. Below are the most important changes:
Auto-Update Language Definitions:
Added a new
updateLanguageDefinitionsmethod toConfiguration, allowing language comment block definitions to be updated at runtime without requiring an extension host reload.The extension now listens for changes to relevant configuration settings in the
activatefunction and automatically updates language definitions and reconfigures the comment blocks as needed, removing the pop-up message and the requirement for an extension reload.Performance Improvements:
Accidental cached data mutation prevention and unnecessary disk read improvements:
The
setLanguageConfigurationmethod now deep-clones language configurations before modification to prevent accidental mutation of cached data.The default multi-line language configuration (
default-multi-line-config.json) and the languages to skip (skip-languages.jsonc) files are now read once during initialisation and cached for later use, improving efficiency and reducing redundant disk reads on every loop iteration.Writing of Language Definition Files and Logging Enhancements:
The extension no longer writes the current language definitions to JSON files in
production, they are only written indevelopmentandtestingmodes for easier debugging and quick reference during development, and preventing unnecessary file writes in production.Refactored the debug logging in the
logDebugInfomethod to use the existing cached language definitions instead of reading from files, improving efficiency.These changes collectively improve the maintainability, performance, and experience of the extension.