be5invis / vscode-custom-css

Custom CSS Plugin for Visual Studio Code. Based on vscode-icon
MIT License
878 stars 67 forks source link

Calling "Enable Custom CSS and JS" with custom CSS or JS already applied breaks "Disable Custom CSS and JS" #151

Closed itsjfx closed 3 years ago

itsjfx commented 3 years ago

Basically the title:

The extension allows the user to call "Enable Custom CSS and JS" with custom CSS/JS already applied and when it does it creates a brand new backup which have whatever custom CSS/JS you have applied in your current session. If a user selects this option accidentally instead of "Reload" then they cannot rollback to the original workbench.html unless they go into the file system themself and restore the backup.

Also if the user keeps calling "Enable Custom CSS and JS" it will just create a backup file for each time they run this command.

If the user tries to rollback using "Disable Custom CSS and JS" then it will rollback to their previously styled version (not the original workbench file) and it will remove all the backup files so there's actually no way for them to rollback unless they reinstall or grab the file from https://github.com/microsoft/vscode/blob/main/src/vs/code/electron-browser/workbench/workbench.html

Suggested fixes:

  1. If "Enable Custom CSS and JS" is called when workbench.html is already modified it will just do what cmdReinstall does so its possible for people to roll back to the original workbench.html file
  2. (If this is even possible) hide the "Enable Custom CSS and JS" option if they have already applied a style

Also if you do this you lose both lines of your CSP not just the first one since it will run the code to remove the first CSP policy again.