Skip to content

Commit 4d6d05d

Browse files
Sort CMakeLists.txt by depth (#3789)
* Sort CMakeLists.txt by depth * Add changes to CHANGELOG.md --------- Co-authored-by: Garrett Campbell <[email protected]>
1 parent a2642d3 commit 4d6d05d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Improvements:
2828
- Add the ability to debug install targets [#532](https://github.com/microsoft/vscode-cmake-tools/issues/532)
2929
- Add a "Don't Show Again" option in the select CMakeLists.txt.
3030
- Log error statement if the environmentSetupScript fails. [#3566](https://github.com/microsoft/vscode-cmake-tools/issues/3566)
31+
- Sort CMakeLists.txt by depth during selection [#3789](https://github.com/microsoft/vscode-cmake-tools/pull/3789) [@jmigual](https://github.com/jmigual)
3132
- [Experiment] Improve CMake Tools experience when opening a folder [#3588](https://github.com/microsoft/vscode-cmake-tools/issues/3588)
3233

3334
Bug Fixes:

src/cmakeProject.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,15 @@ export class CMakeProject {
884884
label: util.getRelativePath(file, this.folderPath) + "/CMakeLists.txt",
885885
fullPath: file
886886
})) : [];
887+
888+
// Sort files by depth. In general the user may want to select the top-most CMakeLists.txt
889+
items.sort((a, b) => {
890+
const aDepth = a.fullPath.split(path.sep).length;
891+
const bDepth = b.fullPath.split(path.sep).length;
892+
893+
return aDepth - bDepth;
894+
});
895+
887896
const browse: string = localize("browse.for.cmakelists", "[Browse for CMakeLists.txt]");
888897
const dontAskAgain: string = localize("do.not.ask.again", "[Don't Show Again]");
889898
items.push({ label: browse, fullPath: "", description: localize("search.for.cmakelists", "Search for CMakeLists.txt on this computer") });

0 commit comments

Comments
 (0)