Skip to content
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

async recursive lookup #52

Open
hoclun-rigsep opened this issue Mar 24, 2023 · 2 comments
Open

async recursive lookup #52

hoclun-rigsep opened this issue Mar 24, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@hoclun-rigsep
Copy link

I don't suppose there is some way to make recursive completion async (like vanilla fzf)?

@rockandska rockandska added the enhancement New feature or request label Mar 29, 2023
@rockandska
Copy link
Owner

Unfortunately, there is no way right now since fzf-obc only read what is in COMPREPLY.
Will try to see in future if there is a way to achieve this while keeping it not too complex

@hoclun-rigsep
Copy link
Author

Okay. I would like to help but I am not sure I have time to figure out how bash completion works. For anyone interested, my workaround is to patch lib/fzf-obc/core-functions.bash thus:

diff --git a/lib/fzf-obc/core-functions.bash b/lib/fzf-obc/core-functions.bash
index 9bdf3b8..71ccdb0 100644
--- a/lib/fzf-obc/core-functions.bash
+++ b/lib/fzf-obc/core-functions.bash
@@ -127,7 +127,7 @@ __fzf_obc_search() {
 
 	local cmd
 	cmd=""
-	cmd="command find ${startdir}"
+	cmd="command bfs ${startdir}"
 	cmd+=" -mindepth ${mindepth} -maxdepth ${maxdepth}"
 	cmd+=" ${exclude_string}"
 	if [[ "${type}" == "paths" ]] || [[ "${type}" == "dirs" ]];then
@@ -165,7 +165,7 @@ __fzf_obc_search() {
 	cmd+=" 2> /dev/null"
 
 	if [[ "${cur_expanded}" != "${cur}" ]];then
-		cmd=" sed -z s'#${cur_expanded//\//\\/}#${cur//\//\\/}#' < <(${cmd})"
+		cmd=" sed -z s'#${cur_expanded//\//\\/}#${cur//\//\\/}#;20000q' < <(${cmd})"
 	fi
 
 	if [[ -n "${xspec}" ]];then

bfs provides the same UI as GNU find but performs searches breadth-first instead of depth-first, and then I limit to 20000 results. You can change that number for what makes sense with your hardware and desired tradeoff between speed and incidence of false negatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants