Fixed lacy prompt behaviour when no args are provided#57
Fixed lacy prompt behaviour when no args are provided#57bladeacer wants to merge 1 commit intotimothebot:mainfrom
Conversation
|
hmm I should probably amend the commit message to be more in line with existing conventions. |
|
Hm, I think the best way would be to do: This would be an empty check then instead of checking for ~. if [ "$new_path" = "~" ]; then
{{ cd }} ~What do you think? |
|
so far from testing base cd and zoxide seem to have the same behaviour when provided with no args. if customising and modifying that behaviour matters you can consider including a config file. |
|
like you mentioned earlier, shell specific scripts are brittle by nature, and this is better handled by the parser itself. if you want to customise the nothing arg behaviour you can consider loading from a yaml or some other config file, or even a set environment variable. would take a bit more work with the parser but that would take a bit more work. as for empty string check in the shell script, that was what I tried to include in #56 . Cheers, bladeacer |
|
I personally prefer having a config file, as you can load from A config schema also lets you be flexible with lacy regardless of shell. At the end of the day, the config file would be better as a separate issue altogether. Like the parser empty string check it would also be something that the author and current maintainers can discuss. |
|
Hm I am usually a fan of config files but I don't see the need for one here. I'm planning to switch to env variables eventually. But that is all besides the issue here. I think lacy should return an empty result if nothing is found. The logic in the script would then just check if the result is empty. Idk why I'm checking arg == ~ rn, that doesn't seem to matter. |
|
Basically the check is there to have default behaviour when lacy prompt is passed no args e.g. just running Did you vibe code a bit here, or were the two pull requests not up to standard? |
|
What two PRs do you mean? I used AI for the initial shell scripts, yes. if [ "$new_path" = "~" ]; then
{{ cd }} ~
{% if custom_fuzzy.enabled %}elif [[ "$new_path" == *$'\n'* ]]; then
selected=$(printf "%s\n" "$new_path" | {{ custom_fuzzy.cmd }})
[ -n "$selected" ] && {{ cd }} "$selected"
{% endif %}elif [ -d "$new_path" ]; then
{{ cd }} "$new_path" || return
else
echo "Error: No matching directory found for '$*'"
fiThis code made sense a few versions ago, but is def outdated now. We don't need to check if the target directory exists. This limits the functionality you might want to give to other apps. That means, whatever single result we get, we can just pass to {{cd}}. But yes, now that im writing this I see that lacy prompt "" should not return nothing because lacy prompt "not existing query" also does. So two questions:
Sorry for the formatting, im currently on my phone^^ |
The PRs as in #57 and #55 , which were made (admittedly hastily) with the amount of information I had at that point in time.
|
|
I won't change the shell scripts for now. I think the error message is fine. If you want anything else, you can always just edit it yourself. In #59, I changed the output to either ~ or, if set, |
is "The ~ check is still required because [ -d "~" ] returns false. :/" still true for the code after #59 is merged? imo like with #59 the immediate fix is nice, but input validation should not so much be handled by the shell script but rather fully by the parser. this will help with support for other shells. cheers, bladeacer |
Fixes #52 .
Not sure if you want more robust logic with this.