-
-
Notifications
You must be signed in to change notification settings - Fork 122
Add setting to disable automatic YAML file association #1026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setting to disable automatic YAML file association #1026
Conversation
While this is a nice option, we should improve the detection on when to enable it... This feels more like a workaround for the problem. |
@frenck - Agreed that this is a workaround and better detection would be great, but I still feel like there should be an option to disable it entirely (ideally default to that behavior being disabled and allow opt-in instead of opt-out). I can't think of any other extension that modifies workspace settings like this, especially creating files when they might not already exist purely for the sake of convenience. Shouldn't need to keep the extension globally disabled and enable per workspace simply to avoid unexpected behavior. Detection is nice and all, but If there's something that you're thinking of that would be a step in a better direction, I'd be happy to modify my PR with the recommended changes. |
I don't agree with that, as it is pretty unique to be |
That's fair if we're parsing the YAML file to check the contents as well! Right now excluding my additions, the fileAssociations section appears to only check if the workspace settings file does not contain a key of There are bits on |
From what I can tell, it looks like the extension is activated for file presence of |
That is correct, I was referring to the fact that it should be improved, not worked around. |
Checking that out! I'm not a TS/JS developer typically, so this should be fun 😄 |
@frenck -- curious if you have some rough implementation guidance here. Seeing your |
I honestly think this is more up into @keesschollaart81 his alley |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds an option to disable the automatic YAML file association for the Home Assistant language without altering the default behavior.
- Introduces the
disableAutomaticFileAssociation
setting in the configuration interface and service. - Updates the extension activation logic to skip file association when the setting is enabled.
- Extends the package schema to include the new boolean setting.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/language-service/src/configuration.ts | Added disableAutomaticFileAssociation to interface and class |
src/extension.ts | Added conditional check for the new setting in file association logic |
package.json | Defined the new setting in the extension’s configuration schema |
Comments suppressed due to low confidence (4)
src/extension.ts:335
- [nitpick] Consider scoping your configuration lookup to your extension's namespace by calling
getConfiguration('vscode-home-assistant')
and then.get('disableAutomaticFileAssociation', false)
for clarity and consistency.
vscode.workspace.getConfiguration()
src/extension.ts:331
- Add a unit or integration test to cover the automatic file association logic when
disableAutomaticFileAssociation
is bothtrue
andfalse
, ensuring both paths behave as expected.
if (
package.json:58
- [nitpick] The indentation for this new setting is slightly misaligned compared to the surrounding properties—align it to improve readability.
"vscode-home-assistant.disableAutomaticFileAssociation": {
Should resolve #961 without changing existing default behavior.
Changes:
vscode-home-assistant.disableAutomaticFileAssociation
(defaults tofalse
).HomeAssistantConfiguration
interface andConfigurationService
class with thedisableAutomaticFileAssociation
property (not currently used, but keeping LS configuration in sync with available configuration options).fileAssociations
section ofextension.ts
with an additional conditional check in theif
statement to read in the new configuration setting.