Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

No autocompletion inside autoclosed pairs #1

Closed
kopischke opened this issue May 10, 2016 · 11 comments
Closed

No autocompletion inside autoclosed pairs #1

kopischke opened this issue May 10, 2016 · 11 comments

Comments

@kopischke
Copy link

Not sure if there is much pisces can do about it, but fish completion breaks inside autocompleted pairs, probably because the closing symbol is then added to the tokens parsed for completion. Without pisces

echo "$<tab>

will complete variable names, but with it

echo "$<tab>"

will offer no completions.

@laughedelic
Copy link
Owner

@kopischke I see the problem, but it's not caused by pisces. I mean that if you uninstall pisces and reproduce the same situation, you won't get completions. Probably it's worth creating an issue in the fish-shell repo.
Anyway, I'll think of a workaround.

@kopischke
Copy link
Author

kopischke commented May 10, 2016

Yes, I am aware that the issue is not caused by pisces (I never said otherwise); the reason I do not consider this a fish issue, but one pisces needs to address, are twofold:

  1. users are highly unlikely to add closing pair characters before trying to complete without pisces, and
  2. it means pisces’ is only of use if you are willing to trade it for one of fish’s most powerful features.

@laughedelic
Copy link
Owner

laughedelic commented May 10, 2016

@kopischke sure, I understand your arguments and I see how pisces brings this issue to the surface.

Here's one probably unrelated observation: if I understand right, complete works on the current token:

complete, guess the remainder of the current token (from man bind)

echo "$|"

(| is the cursor position)

In fish 2.2 commandline --current-token returns $ (ignoring quotes, see fish-shell/fish-shell#2210), while in 2.3 it returns "$". Which version of fish do you use?

Also, can you describe in more details what happens when you hit tab? When I try exactly your example, without the closing quote I don't get any autocomplete and with it cursor jumps outside of it. I need to type at least one character after $ to get some suggestions.

@kopischke
Copy link
Author

kopischke commented May 11, 2016

I’m using fish 2.3 beta 2, and yes, you might need an extra char to get a completion (I’ll have to check next time I’m at my machine). Inside paired characters, I just get a flash of the command line instead of a completion.

@laughedelic
Copy link
Owner

laughedelic commented May 12, 2016

@kopischke I had some chat with a fish developer and it doesn't seem to be solvable by providing some custom completion handling, because you cannot just call pager to complete a given string (it's accessible only internally).

I've made a little demo of what's doable: completing vars inside of double quotes. As you see, when there's only one option, it's easy and nice, but if there are several, I cannot invoke normal fish completion in place. There are different workarounds:

  • in the demo I use choices
  • just list available options so that you can continue typing until you get a single completion
  • external tools like fzf can be used (optinally)

What do you think about it?

Another stupid, but very simple workaround just for the particular type of situations as in your example:

  1. echo $P|<TAB>, you get the completed var: echo $PATH |
  2. cut it with <Ctrl>+W, you have now just echo |
  3. type ", now you're inside the quotes pair
  4. yank the var with <Ctrl>+Y, you have: echo "$PATH |"

@kopischke
Copy link
Author

Well, that is a pity, albeit not entirely unexpected. I am afraid that means I will have to pass on using pisces: omnipresent, uncomplicated, quasi magical auto completion is what sold me on fish; even the nicest plugin (and pisces is very nice) is not worth compromising that. Would you like to keep the issue open to track it or shall I close?

@laughedelic
Copy link
Owner

laughedelic commented May 13, 2016

Sure, I'll keep it open. As I see it, pisces gets in your way only when initially typing text, because if you already have a double quoted string (with or without pisces), you cannot autocomplete anything inside of it. A workaround could be to bind the tab key to delete " in front of the cursor (if there is one) and call complete: so you get autocomplete and have to close the quotes manually as if you didn't use pisces, while in other cases it still works as before. Do you think this could be useful?

I am afraid that means I will have to pass on using pisces

If the only problem is about double quotes and you don't want any of the suggested workarounds, why not just disabling this particular pair, while keeping the rest? There is a setting for that:

> echo $pisces_pairs
(,) [,] {,} "," ','
> set -e pisces_pairs[4]
> echo $pisces_pairs
(,) [,] {,} ','

You can just set it as you like.

Or do you have more similar issues?

@laughedelic
Copy link
Owner

laughedelic commented May 13, 2016

A workaround could be to bind the tab key to delete " in front of the cursor (if there is one) and call complete: so you get autocomplete and have to close the quotes manually as if you didn't use pisces, while in other cases it still works as before.

A little demo of this overriden tab:
pisces_tab_cropped_ann

A curious thing about fish completion is that after completing a token that starts with ", it closes quotes automatically, so you don't need to do anything 👍
@kopischke if this works for you, I will add it in the next release.

@kopischke
Copy link
Author

@laughedelic now that sounds like an excellent workaround. Would love to see that make the next release.

@laughedelic
Copy link
Owner

@kopischke you can try it 😉 fisher up pisces

@kopischke
Copy link
Author

@laughedelic very nice, I’m in love with pisces again. I stumbled on an issue with the new completion wrapper, though, see #2.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants