Skip to content

Conversation

@radurentea
Copy link
Collaborator

Removed previous activation events for file types:

"workspaceContains:**/project_description.json",
"workspaceContains:**/sdkconfig",
"workspaceContains:**/CMakeLists.txt"

We only check for CMakeLists.txt at root project folder if it includes "include($ENV{IDF_PATH}/tools/cmake/project.cmake)"

Description

Please include a summary of the change and which issue is fixed.

Fixes #1414

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Steps to test this pull request

  1. When opening an ESP-IDF project, the extension should still activate itself (ex: commands from esp-idf should be visible in status bar)
  2. When opening a folder that it's not an esp-idf project there should be two scenarios:
    a. If it contains a CMakeLists.txt at the root level which doesn't contain the text include($ENV{IDF_PATH}/tools/cmake/project.cmake) extension should ask, using a notification, if you want to activate esp-idf extension anyway.
    b. If it doesn't contain a CMakeLists.txt at all, it should not activate automatically.
  3. This feature should work with workspaces that include multiple esp-idf projects. If at least one of the projects in the workspace contains a valid esp-idf project, the extension should activate itself.

How has this been tested?

As described above

Test Configuration:

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

Checklist

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

@radurentea radurentea requested a review from brianignacio5 May 23, 2025 11:45
@radurentea radurentea self-assigned this May 23, 2025
@github-actions
Copy link

github-actions bot commented May 23, 2025

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.

We need to consider multiple projects scenario.

@radurentea radurentea requested a review from brianignacio5 May 28, 2025 06:56
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.

LGTM

@radurentea radurentea added this to the v1.11.0 milestone Jun 3, 2025
@github-actions
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 Jun 19, 2025
@radurentea radurentea removed the stale Stale PR or Issue label Jun 20, 2025
Removed previous activation events for file types.
We only check for CMakeLists.txt at root project folder if it includes "include($ENV{IDF_PATH}/tools/cmake/project.cmake)"
- No matter the order of the projects, if an idf extension is present, extension will activate itself.
- If no idf project is detected, but CMakeLists.txt is detected at root level user is asked if he wants to activate extension
If there were folders without CMakeLists.txt file in root, but they had a CMakeLists.txt file in there subfolders, the extension would have activated
Refactored the activation check to search for any CMakeLists.txt in the workspace and verify if it is an ESP-IDF project, rather than only checking root folders. Updated localized messages in Spanish, Portuguese, Russian, and Chinese to reflect the new logic and provide clearer prompts to users.
@radurentea radurentea force-pushed the feature/custom-file-type-activation branch from d6ab91c to 254747e Compare July 1, 2025 15:55
@Fabricio-ESP Fabricio-ESP self-requested a review July 1, 2025 16:20
Copy link
Collaborator

@Fabricio-ESP Fabricio-ESP left a comment

Choose a reason for hiding this comment

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

Confirmed extension tracks CMakeFiles.txt.
Note file is case sensitive.

@radurentea radurentea requested a review from brianignacio5 July 1, 2025 17:19
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.

The PR validates CMakeLists.txt only. Using "**/{build,node_modules}/**" seems unnecessary.

src/extension.ts Outdated
if (PreCheck.isWorkspaceFolderOpen()) {
const cmakeListsFiles = await vscode.workspace.findFiles(
"**/CMakeLists.txt",
"**/{build,node_modules}/**"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need node_modules? Isn't it from JavaScript Typescript projects ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The build folder is also used in CMake project or many other kind of projects. The next validation is only for CMakeLists.txt so I'm just wondering why other files are needed here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The vscode.workspace.findFiles expects as a second argument an exclusion pattern. I just thought it would be good to ignore searching in file such as "node_modules" and "build", if they are present in the opened workspace.

This was the exact thing I wanted to discuss about this new implementation: I can remove the "node_modules" if you think it's unnecessary or add these exclusion patterns for other languages as well, to increase performance of vscode.workspace.findFiles

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see.

Remember that the extension is activated either by running command or "workspaceContains:**/CMakeLists.txt"

Later you can use loop of all workspaceFolders with a relative pattern per workspace folder validation for root only:

const relativePattern = new RelativePattern(workspaceFolderUri, "CMakeLists.txt");
const files = await workspace.findFiles(relativePattern);

The content you are validating is for ESP-IDF root CMakeLists.txt only, so no need to check additional places.

Copy link
Collaborator Author

@radurentea radurentea Jul 3, 2025

Choose a reason for hiding this comment

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

I have changed the implementation once again based on our discussion only needing the CMakeLists.txt from root level. There is no need to use workspace.findFiles() anymore. I've left more details in the commit description

- Replace recursive CMakeLists.txt search with root-only validation
- Use direct file system checks instead of workspace.findFiles for better performance
- Support multiple workspace folders with ESP-IDF projects at root level
- Maintain user prompt for non-ESP-IDF CMakeLists.txt files
@radurentea radurentea requested a review from brianignacio5 July 3, 2025 11:58
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.

LGTM

@radurentea radurentea merged commit 3bd2221 into master Jul 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically Detect Project Files to Activate ESP-IDF Plugin (VSC-1578)

4 participants