Skip to content
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

Update with DefaultExtensions everytime when opening C# project in VSCode #86

Closed
Hamster5295 opened this issue Dec 15, 2023 · 0 comments · Fixed by #89
Closed

Update with DefaultExtensions everytime when opening C# project in VSCode #86

Hamster5295 opened this issue Dec 15, 2023 · 0 comments · Fixed by #89
Assignees
Labels
bug Something isn't working

Comments

@Hamster5295
Copy link

Current Behavior

Hello!

I'm currently working on applying a new file extension to EditorSettings.projectGenerationUserExtension, so that Unity could open the file as well as the C# project in VSCode upon double-clicking those files in the Project window.

However, the modification in EditorSettings.projectGenerationUserExtension doesn't work, my extension not showing in the "Extensions handled" field in the "Configure Extensions Handled by VSCode" sector, until I click on the "Reset to default" button. That's NOT my desired behavior of it being updated Automatically.

Looking into the source code, I find the problem lies in the DefaultExtensions member in com.tsk.ide.vscode/Editor/VSCodeScriptEditor.cs.
VSCodeScriptEditor applys the extensions using EditorPrefs.GetString(vscode_extension, string.Join(";", DefaultExtensions)) in the OpenProject(string, int, int) method, which means DefaultExtensions, including EditorSettings.projectGenerationUserExtension I modified, is never updated into the EditorPrefs after the first time It is called, unless clicking on the Reset to default button.

Maybe updating the extensions stored in EditorPrefs using DefaultExtensions at the beginning of the method OpenProject(string, int, int) could solve this issue. Thank you!

Reproduction / Steps To Reproduce

  1. Add an extension into the EditorSettings.projectGenerationUserExtension field. In my case, I called it from an Awake() in an ScriptedImporter Subclass, and has validated that the code actually runs with a Debug.Log(). My code goes like this:
string[] exts = new[] { "myext" };
EditorSettings.projectGenerationUserExtensions =
    EditorSettings.projectGenerationUserExtensions.Concat(exts).Distinct().ToArray();
  1. Look into the "Extensions handled" field in the "Configure Extensions Handled by VSCode" sector, and you'll not find the "myext" extension between those extension.
  2. Click on the "Reset to default" button, and "myext" now appears.

Anything else?

No response

@Hamster5295 Hamster5295 added the bug Something isn't working label Dec 15, 2023
@Chizaruu Chizaruu self-assigned this Feb 21, 2024
@Chizaruu Chizaruu mentioned this issue Feb 21, 2024
@Chizaruu Chizaruu linked a pull request Feb 21, 2024 that will close this issue
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 a pull request may close this issue.

2 participants