Skip to content

Load .wt.json snippets from parent directories #18904

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

Merged
merged 2 commits into from
May 14, 2025

Conversation

carlos-zamora
Copy link
Member

Summary of the Pull Request

Adds logic such that local snippets from .wt.json files are imported not only at the current directory, but also in the parent directories.

References and Relevant Issues

Spec: https://github.com/microsoft/terminal/blob/main/doc/specs/%231595%20-%20Suggestions%20UI/Snippets.md

Validation Steps Performed

D:\test\.wt.json: contains Hello --> hello (parent)
D:\test\inner_dir\.wt.json: contains Hello --> hello

  • In D:\test\...
    • Hello command outputs hello (parent)
    • ✅ commands from inner_dir not shown
  • In D:\test\inner_dir\...
    • Hello command outputs hello
    • ✅ commands from D:\test are shown

PR Checklist

Closes #17805

@carlos-zamora carlos-zamora requested a review from zadjii-msft May 13, 2025 21:03
Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

Just nits.

Comment on lines 965 to 966
directories.push_back(directory);
const auto parentPath = directory.parent_path();
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the string copy, but it looks ugly so maybe don't.

Suggested change
directories.push_back(directory);
const auto parentPath = directory.parent_path();
auto parentPath = directory.parent_path();
const auto done = directory == parentPath;
directories.push_back(std::move(directory));
if (done)
{
break;
}
directory = std::move(parentPath);

@carlos-zamora carlos-zamora merged commit 92e8be4 into main May 14, 2025
19 checks passed
@carlos-zamora carlos-zamora deleted the dev/cazamor/local-snippets branch May 14, 2025 17:34
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.

We should recurse upwards when looking for local snippets
2 participants