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

counsel-find-file TAB gets stuck on certain paths with spaces #2103

Closed
gusbrs opened this issue Jun 21, 2019 · 5 comments
Closed

counsel-find-file TAB gets stuck on certain paths with spaces #2103

gusbrs opened this issue Jun 21, 2019 · 5 comments

Comments

@gusbrs
Copy link
Contributor

@gusbrs gusbrs commented Jun 21, 2019

I found a corner case in the workings of counsel-find-file which was pulling my leg for some time, but I had never stopped to try to understand what was really going on. Today I did, and report.

Steps followed:

$ emacs -Q
M-x package-initialize RET
M-x counsel-mode RET

Let’s say we have the following directory structure:

~/foo/
    barbazi/
    barbazii/
        goal.txt

Now we try to navigate the tree:

"C-x C-f" foo TAB (we are inside "~/foo/")
"C-n" "C-n" "C-n" TAB TAB (we are inside "barbazii/")
"C-n" "C-n" TAB TAB

And we reached goal.txt.

Now we add two things:

M-: (setq ivy-extra-directories nil) RET

and spaces in the directory tree:

~/foo/
    bar baz i/
    bar baz ii/
        goal.txt

And try it again:

"C-x C-f" foo TAB (we are inside "~/foo/")
"C-n" TAB TAB TAB TAB "C-p" TAB TAB TAB TAB

And we get stuck. ("C-j" does work though).

Now if there is another arbitrary directory there:

~/foo/
    bar baz i/
    bar baz ii/
        goal.txt
    foo sub/

then we can reach "goal.txt" again.

So, as far as I can tell, the situation arises when all candidates share a common initial string up to a space.

Indeed, the fontification suggests that the TAB completion gets stuck in the first space after the common part in the names of the two directories.

Either the default value of ivy-extra-directories or an arbitrary third directory breaks this condition, and TAB TAB works as expected.

Environment: Emacs 26.2, counsel-20190619.512, ivy-20190613.1539, Linux Mint 19.1 Cinnamon

@abo-abo abo-abo closed this in 51e765e Jun 25, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jun 25, 2019

Thanks, please test.

@gusbrs
Copy link
Contributor Author

@gusbrs gusbrs commented Jun 25, 2019

@abo-abo Thank you very much for looking into this.

I had to wait a little for the fix to get propagated through MELPA, but it got here now. It does indeed succeed in the example I initially provided. But I could still generate the problem with a slightly different directory structure. Namely:

~/foo/
    bar baz (abc)/
    bar baz i/
    bar baz ii/
        goal.txt

Edit: What was wrong with the other "unexpected behavior" I mentioned was my expectation. Now I get it (#2007 (comment)).

Tests performed with ivy-20190625.2017 and counsel-20190624.1444.

@gusbrs
Copy link
Contributor Author

@gusbrs gusbrs commented Aug 6, 2019

@abo-abo If I may gently ping you on this one, in case this got lost in the issue overflow. (If this was not the case, please disregard, with my apologies).

abo-abo added a commit that referenced this issue Aug 7, 2019
When `ivy-text' was "foo bar ", `parts' becomes '("foo" "bar"), and
`new' becomes "bar ", which is different from the last element of
`parts'. This is now detected.

Fixes #2103
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Aug 7, 2019

Thanks, please test.

@gusbrs
Copy link
Contributor Author

@gusbrs gusbrs commented Aug 7, 2019

It's working nicely indeed now. Thank you very much!

astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
* ivy-test.el (counsel-find-file-with-spaces): Add tests.

Fixes abo-abo#2103
astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
When `ivy-text' was "foo bar ", `parts' becomes '("foo" "bar"), and
`new' becomes "bar ", which is different from the last element of
`parts'. This is now detected.

Fixes abo-abo#2103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants