Skip to content

Commit

Permalink
Sort CMakeLists.txt by depth (#3789)
Browse files Browse the repository at this point in the history
* Sort CMakeLists.txt by depth

* Add changes to CHANGELOG.md

---------

Co-authored-by: Garrett Campbell <[email protected]>
  • Loading branch information
jmigual and gcampbell-msft authored May 29, 2024
1 parent a2642d3 commit 4d6d05d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Improvements:
- Add the ability to debug install targets [#532](https://github.com/microsoft/vscode-cmake-tools/issues/532)
- Add a "Don't Show Again" option in the select CMakeLists.txt.
- Log error statement if the environmentSetupScript fails. [#3566](https://github.com/microsoft/vscode-cmake-tools/issues/3566)
- Sort CMakeLists.txt by depth during selection [#3789](https://github.com/microsoft/vscode-cmake-tools/pull/3789) [@jmigual](https://github.com/jmigual)
- [Experiment] Improve CMake Tools experience when opening a folder [#3588](https://github.com/microsoft/vscode-cmake-tools/issues/3588)

Bug Fixes:
Expand Down
9 changes: 9 additions & 0 deletions src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,15 @@ export class CMakeProject {
label: util.getRelativePath(file, this.folderPath) + "/CMakeLists.txt",
fullPath: file
})) : [];

// Sort files by depth. In general the user may want to select the top-most CMakeLists.txt
items.sort((a, b) => {
const aDepth = a.fullPath.split(path.sep).length;
const bDepth = b.fullPath.split(path.sep).length;

return aDepth - bDepth;
});

const browse: string = localize("browse.for.cmakelists", "[Browse for CMakeLists.txt]");
const dontAskAgain: string = localize("do.not.ask.again", "[Don't Show Again]");
items.push({ label: browse, fullPath: "", description: localize("search.for.cmakelists", "Search for CMakeLists.txt on this computer") });
Expand Down

0 comments on commit 4d6d05d

Please sign in to comment.