-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commands "Add File to Cody", "Add Selection to Cody" and shallow folder #10
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
Also contains adding shallow directory together with non-shallow directory now, so will close #2 |
Thank for the PR @Yandrik. Will review it later |
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.
Hi @Yandrik , happy new year!
Forgive me for the late review, I think overall this PR is good, thanks for your contribution 🚀
Just left some thoughts and modifications to make it more intuitive. Feel free to discuss!
package.json
Outdated
{ | ||
"command": "cody-plus-plus.addFile", | ||
"when": "resourceScheme == file && !explorerResourceIsFolder && cody.activated", | ||
"group": "0_cody" | ||
}, | ||
{ | ||
"command": "cody-plus-plus.addSelection", | ||
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated", | ||
"group": "0_cody" | ||
}, | ||
{ | ||
"command": "cody-plus-plus.addFolder", | ||
"when": "explorerResourceIsFolder && cody.activated", | ||
"group": "0_cody" | ||
}, | ||
{ | ||
"command": "cody-plus-plus.addShallowFolder", | ||
"when": "explorerResourceIsFolder && cody.activated", | ||
"group": "0_cody" | ||
} |
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 think when users select multiple folders and files, we should show (only) Add Multiple Files option. This is likely their expected behavior.
Also, we should hide the “Add File…” command when the user right-clicks on the folder (because it should only be used for adding individual files). We can achieve this by adding !explorerResourceIsFolder
to the condition property.
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.
{ | |
"command": "cody-plus-plus.addFile", | |
"when": "resourceScheme == file && !explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addSelection", | |
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addFolder", | |
"when": "explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addShallowFolder", | |
"when": "explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
} | |
{ | |
"command": "cody-plus-plus.addFile", | |
"when": "!explorerResourceIsFolder && !listMultiSelection && explorerViewletFocus && resourceLangId && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addSelection", | |
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addFolder", | |
"when": "!listMultiSelection && explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addShallowFolder", | |
"when": "!listMultiSelection && explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
} |
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.
The add file change is a really good idea! I totally overlooked that :)
I think keeping the addFolder and addShallowFolder options available even when a user has selected some files can be useful. I've run into the situation of wanting to select multiple files for adding, but also adding a shallow folder multiple times (e.g. in a SvelteKit project I select the homepage and contact +page files and also shallow folder of contact page to e.g. better integrate it into the homepage. This will cause some dual selections, but that's fine as Cody internally dedups this)
Do you think that's reasonable, or not a good idea?
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.
This suggestion keeps both folder and file adds in place even when right-clicking a selection. Not sure if that's a good idea, but I think it'll make Cody++ more flexible for several usecases
{ | |
"command": "cody-plus-plus.addFile", | |
"when": "resourceScheme == file && !explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addSelection", | |
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addFolder", | |
"when": "explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addShallowFolder", | |
"when": "explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
} | |
{ | |
"command": "cody-plus-plus.addFile", | |
"when": "!explorerResourceIsFolder && explorerViewletFocus && resourceLangId && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addSelection", | |
"when": "listMultiSelection && explorerViewletFocus && listHasSelectionOrFocus && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addFolder", | |
"when": "explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
}, | |
{ | |
"command": "cody-plus-plus.addShallowFolder", | |
"when": "explorerResourceIsFolder && cody.activated", | |
"group": "0_cody" | |
} |
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.
Can you maybe provide an example? I do not really get your use cases since both commands actually do not make any difference in my test video
CleanShot.2025-01-02.at.23.44.44.mp4
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.
Problems
Currently, when >1 file is selected, the "add selection" command always shows up in the right click menu. When run on a file that isn't in the selection, it adds only that file, nothing else. I haven't found a way to prevent it from showing up in that situation :/
That's also the issue I ran into before, and I didn't find any way to fix this. That's why I abandoned the "Add Selected Files" being only visible when actually clicking on a list - if there's already a file selected, then VSCode will consider any right-clicked file or folder to be part of that list, no matter what unfortunately.
I've spent quite a few hours to work around this, but never managed
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.
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.
Will do! 😄
Happy new year!
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.
@Yandrik Got that! Also, can you leave your X account here? I can give you a shout out when I release a new version to acknowledge your contribution (if you feel okay with that).
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 don't actually have an X account ^^
If you want to mention me, just the GitHub username is just fine 😄 Thanks!
Just like the title sais, this is what the new features do.
Add File to Cody
Does the same thing as Add Folder to Cody, just for files

Add Selection to Cody
Select some files with

ctrl+mouse1
, right-click on the selection and run the command, and all files and folders that are selected will be added to CodyProblems
Currently, when >1 file is selected, the "add selection" command always shows up in the right click menu. When run on a file that isn't in the selection, it adds only that file, nothing else. I haven't found a way to prevent it from showing up in that situation :/