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

Enhance/uninstall improvement #1353

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

radurentea
Copy link
Collaborator

Description

Added command for the user to remove all esp-idf settings from the settings.json files that can be opened with:

Preferences: Open Workspace Settings (JSON) (workspace Folder)
Preferences: Open User Settings (JSON) (global settings)

And also the settings from .code-workspace (multi-project)

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Steps to test this pull request

Remove all settings using the command ESP-IDF: Remove ESP-IDF Settings

How has this been tested?

Used the command and saw all the settings were removed as expected.

Test Configuration:

  • ESP-IDF Version: 5.3.1
  • OS (Windows,Linux and macOS): Windows

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Copy link

github-actions bot commented Nov 29, 2024

Download the artifacts for this pull request:
You can test these changes by installing this VSIX by click menu View -> Command Palette..., type Install from VSIX and then select downloaded esp-idf-extension.vsix file to install the extension.

Copy link
Collaborator

@brianignacio5 brianignacio5 left a comment

Choose a reason for hiding this comment

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

Some changes regarding code structure.

try {
// Try to remove from each scope, but handle errors silently
// Global settings
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can simplify this code by reusing these try catch code into a single helper function that receives vscode.ConfigurationTarget.{Global, Workspace, WorkspaceFolder} and inspection?.{workspaceValue, globalValue, workspaceFolder} !== undefined arguments.

);
}

async function removeEspIdfSettings() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason why we can't have this function outside the extension.ts code ? We could move the code into a separated file.

// Get all settings directly from configuration
const allSettings = config.inspect("");
// Check values saved in each scope
if (allSettings?.globalValue) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

findIdfSettings can be simplified into a for loop with an array [allSettings.globalValue, allSettings.workspaceValue, allSettings.workspaceFolderValue]

Copy link

Pull request has been marked as stale since there are no activities, and this will be closed in 5 days if there are no further activities

@github-actions github-actions bot added the stale Stale PR or Issue label Dec 20, 2024
@Fabricio-ESP Fabricio-ESP added ongoing Ongoing Issue or PR, this label will be used for issue or PR which is to be excluded by stale bot and removed stale Stale PR or Issue labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ongoing Ongoing Issue or PR, this label will be used for issue or PR which is to be excluded by stale bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants