extensions
extensions copied to clipboard
fix(visual-studio-code-project-manager): Fix optional Projects Location setting
Description
This PR is a follow up to #11383 with the intent of fixing #11520.
Prior to #11383, the extension used a textField
for a path that should be optionally provided, and I replaced this setting with a directory
type preference with required: false
and without a default, hoping this would make the setting optional.
It seems that sometimes Raycast picks a directory, possibly root (i.e. /
), for this setting type. The extension assumes that if the directory exists it contains data from the companion VSCode extension, but if the wrong directory is passed, this could lead to the errors described in #11520.
This PR reverts back to the previous setting behavior using a textField
. I also improved the error screen that is shown when no projects are found or when the Projects Location field is invalid.
Screencast
Projects Location is now a text field:
Projects Location points to an invalid location:
The VS Code extension is not installed or no projects are saved:
Checklist
- [x] I read the extension guidelines
- [x] I read the documentation about publishing
- [x] I ran
npm run build
and tested this distribution build in Raycast - [x] I checked that files in the
assets
folder are used by the extension itself - [x] I checked that assets used by the
README
are placed outside of themetadata
folder
Thank you for your contribution! :tada:
🔔 @MarkusLanger @GastroGeek @4very @theherk @TobiasYin @yossizahn @eduwass @gadenbuie you might want to have a look.
I'm not sure I understand the fix. Well, I understand the fix, but I'm not clear on why it is warranted. It works as expected when no directory is selected, it works correctly when the correct directory is selected, but it doesn't work correctly when the wrong directory is selected? Is that correct? If so, isn't that expected behavior?
@theherk You're totally right. My working theory is that optional directory-type preferences aren't well defined in Raycast. I noticed in testing that the directory setting would sometimes be filled with a value even if I had cleared it previously. I was testing this code path so I assumed it was that I had gotten into a weird state locally, but the user report changed my mind.
If Raycast automatically fills in the directory option, though, it can break the extension in non-obvious ways, which is why it seems safer to use the textField
type where it's very obvious that the value is or is not set.
Cool. Makes sense to me. It would be good if somebody in the Raycast team could comment on the expected behavior of the directory
type preference.
directory
will return the path if the path exists, it can be removed since it was added to preferences so it would be better to check for that. Does that make sense?
directory
will return the path if the path exists, it can be removed since it was added to preferences so it would be better to check for that. Does that make sense?
Hi @pernielsentikaer, sorry I'm not sure I follow. Maybe I can clarify: a key detail is that the extension does not require the preference using the directory. In fact, the extension fails badly if the user picks the wrong directory, especially if that directory exists.
In my testing I noticed some unusual behavior around this preference. At the moment, I can't even set "required": false
for the preference using the code in this PR. When I do, Raycast gives me the "Before you start using this extension" screen and forces me to pick a folder. That is not good (picking a folder isn't great and is probably only used by a small number of people).
What I've seen so far is that "type": "textfield"
works a lot better as a non-required field. This particular preference is an expert level preference, it's completely appropriate that it be slightly less easy to use. That said, this PR adds a few conveniences so that it's not a complete pain to use this preference.
Another question for you @pernielsentikaer: I've worked on a few more improvements to the extension to bring frecency sorting to the project list. Would it be better to add those to this PR so they can be reviewed at once or to open a new PR?
It should be possible to set default:false
for directory, I just tried with this code and it works as expected
{
"name": "test",
"type": "directory",
"required": false,
"label": "Test",
"title": "Test",
"description": "Test",
"default": true
}
I think it might be a good idea to open a new PR after this with the new stuff 🙂
It should be possible to set
default:false
for directory, I just tried with this code and it works as expected
Thanks. For me "default": true
(or false
) shows a type error squiggle (Incorrect type. Expected "string".
)
I've figured out my confusion, though. For some reason I was landing on this screen
I didn't realize that I could a) clear the selection from this screen or b) move forward without picking a directory by activating "Continue".
I hear you that the directory
type would be preferable and I'm hoping I was landing on the above screen just because I got into a weird state during local dev. I just pushed an update to go back to the directory
type preference.
So is there visually no difference between picking /
and not picking a directory?
I'd also like to know that @gadenbuie
No, I can't really explain the /
above or how I got into that state or why that screen appeared for me. To fix it, I'm pretty certain I first cleared the selection and then moved forward, at which point everything worked like normal again. Having done that, I can't get the extension back into the weird state.
Now that things are working, though, there is a difference between picking /
and not picking a directory. When /
is selected..
...the extension now shows the new informative error screen because the expected json files don't exist there.
Is the ready for a review?
Is the ready for a review?
Yes, thank you
@MarkusLanger are you still around?
Yes, if it works, that's fine with me.
I just tried to clear everything and start over; now I'm experiencing a crash.
Could you handle that gracefully, @gadenbuie?
I just tried to clear everything and start over; now I'm experiencing a crash. ... Could you handle that gracefully
Thanks for catching that @pernielsentikaer. It should be fixed now.
Published to the Raycast Store: https://raycast.com/MarkusLanger/vscode-project-manager
:tada: :tada: :tada:
We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.