-
Notifications
You must be signed in to change notification settings - Fork 88
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
Auto prepend ./ for quick directory change doesn't work if directory starts with . #171
Comments
I'd be happy to take a shot at fixing this with some guidance unless it's a quick fix for someone else to do. |
Hi Paul! Welcome and thanks for reporting the bug.
You mean if you try to hit enter right after selecting |
@kidonng got any ideas on how to fix this? |
That is correct! Edited the original for clarity. |
I guess just adjust the regex to only exclude leading |
It also looks like the test added in that commit only covers |
One fix could be to remove the |
I'm not a regex expert but I think the original fix: The new regex could be simplified to something like: |
That's very creative and great in-depth analysis. I think the regex However, all of this thinking in this area made me realize a better, cleaner solution
The PR for this is #185. |
Can you give some failing examples?
I think you mean
Only when path starts with
You quoted "I think I'm inclined to add this to fd by default. I don't really see any drawbacks." and that's in contrary to "this is safe to do".
The current way doesn't need checking and hence has no performance hindering.
That's exactly the thoughts behind #76, i.e. the current behavior.
I can't say I use that often, but occasionally it's very nice. I will miss it if you really decided to drop it. TL;DR I'm opposed to reverting to appending
|
It excludes hidden files. In fact, it's no different from
No I tested them using a regex tester on different paths.
You're right. But if or when fd appends / to directories outputted, then I can just remove all these checks to append / to directories, because they'll already be there. Search directory's code will become much simpler.
Right, but we're talking probably less than 1 ms difference.
Are you saying you think prepending ./ is more natural than appending /?
True, it affects symlinks. But remember that if you already start typing something into the command line, e.g.
That's good to hear you've been using it. But I think you represent one of the more advanced power users of fzf.fish. I need to consider all fzf.fish users, and for many of them I suspect this feature is not used and prepending ./ is more confusing and unnatural than appending /. However, the main reason I want to remove it, as I've stated before, I deeply regret how much feature creep has gone into search directory and I think it's time to cut back. I am losing time and motivation because of maintaining a feature I don't use very much (look up the commit history to see how many bugs we've had to fix in search directory; I'm really sick of it). By removing one small feature, it should reduce the surface area and complexity that is causing bugs. If you look at my PR, the code and documentation shrinks and becomes easier to read. I'm really sorry I'm going to remove this feature you originally worked on. I'm still grateful for all the work you've poured into this and hope you will continue to do so. I hope you can understand. However, I will await your reply before proceeding because I find that 50% of the time, you convince me to change course anyway--I respect that your judgment, experience, and shell prowess is generally greater than my own. |
I decided appending / is a better, cleaner solution for quick cd than appending ./ - since prepending ./ is causing issues when the path starts with . or /, why not just append /? fd never appends / to its output so this is safe to do (see sharkdp/fd#436) - of course, we can't just append / to everything; we need to test if the path is actually a directory, but since we only do this when there's one path selected, it's not performance hindering - a / at the end of only directories is cleaner, more natural, and has a more comprehensible than prepending ./ to anything even when it's not needed - the code and documentation become much more straightforward - this will remove support for executables, which cuts back on product debt - fixes #171 (is compatible with hidden directories) This is about the same as the PR that started this all (#72) except we're using a trailing / instead. Do note that symlink behavior changes if the directory has a trailing / (#185 (comment)).
I just convinced myself this is not in line with what Fish does: they append
While I do not consider myself to be of anything you described, thanks for your kind words. I love your carefulness, inclusive thoughts as detailed documentation as well. |
Great! Excellent points. Even if you didn't agree, I hope you know that I very much value your insight and contributions and it hurts me as well to reject your excellent ideas. It's usually not an easy call. |
Describe the bug
When selecting a directory that begins with
.
, the result is not prepended with./
andfish
gives an error:fish: Unknown command: .config
.To Reproduce
set -x fzf_fd_opts -H
cd
to a folder with folders beginning with.
C-f
to trigger__fzf_search_current_dir
.config
that begins with a.
and pressenter
to select itenter
againExpected behavior
Prepend with
./
so that the secondenter
does acd
into the folderScreenshots
N/A
Environment
3.1.2
fisher update
prior to posting this bug so it should be latest as of this bug reportfisher 4.3.0
kitty
debian-based
Additional context
This appears to have been introduced by b19e3f8 which has a regex check for a path used as the base directory and as a side effect explicitly does not add the
./
to folders beginning with.
.The text was updated successfully, but these errors were encountered: