-
Notifications
You must be signed in to change notification settings - Fork 214
Create new queries in selected folder of queries panel #3012
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
Conversation
b5a416c to
6b741b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't taken a really close look at the code yet, but I've been trying to get it to work locally!
At the moment, I can't create a query inside most folders because the codeql-custom-queries-xxx folder doesn't exist. E.g. when highlighting the ql/cpp/ql folder, I get
Could not create query example file: Error: ENOENT: no such file or directory, scandir 'c:\git-repo\vscode-codeql-starter\ql\cpp\ql\codeql-custom-queries-cpp'
Am I missing something about to use this? 😅 Or maybe I'm hitting a Windows bug 🐛 👀
This will change the behavior of the "Create new query" command to create the new query in the same folder as the first selected item in the queries panel. If no items are selected, the behavior is the same as before. I've used events to communicate the selection from the queries panel to the local queries module. This is some more code and some extra complexity, but it ensures that we don't have a dependency from the local queries module to the queries panel module. This makes testing easier.
Before, if you had selected a folder or file within for example `codeql-custom-queries-java` and selected `java` as the language, it would create a nested folder within `codeql-custom-queries-java` with the name `codeql-custom-queries-java`. This is unexpected for the user, who would expect a new query to be created within `codeql-custom-queries-java`. This fixes that by checking for this specific condition. It does not fix it for all scenarios, such as where the selected file/folder is nested multiple levels deep within the `codeql-custom-queries-java` folder.
6b741b4 to
f0f5538
Compare
I was testing in a different workspace which didn't have the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks good to me! And thank you for fixing the no such file or directory errors I had earlier 📂 🎉
One more thing I'm wondering about (but feel free to just merge this and potentially follow up with James later):
Could we create the query (and the ql pack) directly inside the highlighted folder, instead of nested inside a codeql-custom-queries-* folder? E.g. in this video, I'd expect the query to be created directly inside example/snippets, since that's what the file explorer does.
create-query-inside-folder.mp4
However, it might be awkward to make sure we're in a suitable QL pack, so perhaps this isn't feasible!
|
Thanks @shati-patel, I agree that that behavior would be more useful. I've created an internal issue to track this, but I'll merge this now since it's already an improvement over the previous behavior. |
This will change the behavior of the "Create new query" command to create the new query in the same folder as the first selected item in the queries panel. If no items are selected, the behavior is the same as before.
I've used events to communicate the selection from the queries panel to the local queries module. This is some more code and some extra complexity, but it ensures that we don't have a dependency from the local queries module to the queries panel module. This makes testing easier.
Checklist
ready-for-doc-reviewlabel there.