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

Fix random file being chosen to create project #190

Merged
merged 1 commit into from
Nov 16, 2023
Merged

Conversation

tristan957
Copy link
Contributor

No description provided.

@tristan957 tristan957 merged commit e667416 into main Nov 16, 2023
5 checks passed

export async function rootMesonFiles(): Promise<vscode.Uri[]> {
const allFiles = (await vscode.workspace.findFiles("**/meson.build")).sort(
(a, b) => a.fsPath.length - b.fsPath.length,
Copy link
Member

Choose a reason for hiding this comment

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

That's the path lenght in chars? Won't it make a/b/meson.build before long_dir_name/meson.build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm you're right. I think I need to sort by file path components

Copy link
Contributor

@wolfpld wolfpld Nov 16, 2023

Choose a reason for hiding this comment

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

If I understand the code correctly, I don't think this would be a problem. The path-length check should be sufficient, since there's no scenario in which you would have found a parent-level meson.build after processing a subdirectory of said parent.

@xclaesse
Copy link
Member

In python I would do:

import os
for root, dirs, files in os.walk("."):
    if "meson.build" in files:
        print(f"Root at {root}")
        # Do not look into subdirs if we found a meson.build file
        dirs.clear()

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.

3 participants