-
Notifications
You must be signed in to change notification settings - Fork 100
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
feat: prefix completion #413
Conversation
Coming here from #384 (comment). Not sure if testing this requires rebuilding the ❯ source fzf-tab.zsh
❯ which build-fzf-tab-module
build-fzf-tab-module () {
-ftb-build-module $@
}
❯ build-fzf-tab-module
cd . && ./.preconfig
./.preconfig: line 5: autoconf: command not found
./Util/preconfig: ./.preconfig failed (status 127)
-ftb-build-module:30: no such file or directory: ./configure
make: *** No targets specified and no makefile found. Stop.
The module building has failed. See the output above for details. I don't understand the error, but after getting it my Anyway I continued to test, in the event that rebuilding wasn't necessary. All tests were completed on the latest MacOS with zsh 5.9. I checked all edge cases discussed so far on #384. All appear to have been resolved. Nice work! However one thing did stand out, which was perhaps intentional but personally I'm not sure I like it... Consider this tree: ❯ TMPDIR=$(mktemp -d) && cd $TMPDIR
❯ mkdir foo bar
❯ touch foo/ba{r,z}
❯ tree -F
./
├── bar/
└── foo/
├── bar
└── baz
3 directories, 2 files If I do this > ls <TAB>
> ls foo/ba While I guess I understand how this behavior would fit into the new "complete longest prefix" paradigm, it was not expected. In particular I didn't expect it to terminate Curious how others feel about this though. I suppose I could be swayed either way, but it was definitely surprising at first. |
And actually, I just tested a slightly different scenario, but the results seem inconsistent: ❯ mkdir foo bar
❯ touch foo/.ba{r,z} # note these are now "hidden" files
❯ tree -Fa
./
├── bar/
└── foo/
├── .bar
└── .baz
3 directories, 2 files When I enter ❯ ls <TAB> and select I suppose it's possible this is due to some zsh configuration about hidden files that's particular to me. But I thought I'd bring it up here for discussion. |
This error is caused by the missing of Not restoring pwd is a bug, fixed in cdc34ee
I agree with you. It breaks the coherence of the continuous completion. fixed in 7b1e083
Yes, this is zsh's default behaviour. See https://man.archlinux.org/man/zshoptions.1.en#GLOB_DOTS |
@cohml |
So everything reported thus far seems to be fixed and working great 👍 But one bizarre thing is happening now. Again I'm unable to figure out if it's just me vs. reproducible by others. But I'll report my observations anyway, just in case. First, note that my local branches are all up to date with the remote: ❯ for branch in master feat/complete-prefix; do git checkout $branch && git pull; done
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
Already up to date.
Switched to branch 'feat/complete-prefix'
Your branch is up to date with 'origin/feat/complete-prefix'.
Already up to date. When I check out But when I check out _zsh_highlight_bind_widgets:zle:46: bad option: -t Important So the only thing that changes between me getting that error and not getting that error is my local This confuses me, because that widget comes from the
... and because the ❯ git -C fzf-tab grep -q _zsh_highlight_bind_widgets && echo matches || echo no matches
no matches Can you speculate what's happening here? Is this a problem with the Note
Apologies if this is a wild goose chase. This one niggle aside, your changes are fantastic :) |
@cohml I think this is because I created a widget called |
Yup, that seems to fix it! I am now out of ideas for further testing. This feature seems to work great - Cheers! All that seems missing is some documentation for it. |
How to enable this? Or, is the default behavior now? Not sure from the documentation, in the PR description says:
|
|
That is strange. With my @Aloxaf Are you sure that line is necessary? |
It depends on your configuration. If you have configured something like |
I see. That may be it, but I don't see anything like that in my #!/bin/zsh
# default fzf settings to apply globally
FZF_TAB_DEFAULT_FZF_FLAGS=(
"--height=~95%"
"--multi" # TODO: still not working for some reason
"--no-exact"
)
zstyle ":fzf-tab:*" fzf-flags "${FZF_TAB_DEFAULT_FZF_FLAGS[@]}"
# when completing environment variables, show their values (wrapped)
# in the preview window ("<unset>" if no value/empty string)
zstyle ":fzf-tab:complete:(-command-|-parameter-|-brace-parameter-|export|unset|expand):*" fzf-flags "--preview-window=wrap" "${FZF_TAB_DEFAULT_FZF_FLAGS[@]}"
zstyle ":fzf-tab:complete:(-command-|-parameter-|-brace-parameter-|export|unset|expand):*" fzf-preview "[[ -n \${(P)word} ]] && echo \${(P)word} || echo \<unset\>"
# don't sort git checkout output
zstyle ":completion:*:git-checkout:*" sort false
# use $ZLS_COLORS to color filenames by type
zstyle ":completion:*" list-colors "${(s.:.)ZLS_COLORS}"
# set descriptions format to enable options to be grouped into "completion groups"
zstyle ":completion:*:descriptions" format "[%d]"
# switch between "completion groups" using ";" and "," keys
FZF_TAB_SWITCH_GROUP_FORWARD_CHAR=";"
FZF_TAB_SWITCH_GROUP_BACKWARD_CHAR=","
zstyle ":fzf-tab:*" switch-group "${FZF_TAB_SWITCH_GROUP_BACKWARD_CHAR}" "${FZF_TAB_SWITCH_GROUP_FORWARD_CHAR}"
# set prefix to prepend to each option (empty string/disabled in this case)
FZF_TAB_OPTIONS_PREFIX_STRING=
zstyle ":fzf-tab:*" prefix "${FZF_TAB_OPTIONS_PREFIX_STRING}"
# clean up namespace
unset FZF_TAB_DEFAULT_FZF_FLAGS \
FZF_TAB_SWITCH_GROUP_BACKWARD_CHAR \
FZF_TAB_OPTIONS_PREFIX_STRING \
FZF_TAB_SWITCH_GROUP_FORWARD_STRING I'm happy to move this to a dedicated issue or discussion if you feel we're straying too far from the original PR. |
Hello dev, I found a bug related in this PR. Please pay attention to the word capitalization in the following example. Previously: $ ls -1
AppName
appname-2
appname-3 Type $ ls app
> app█
3/3 (0)
> AppName
appname-1
appname-2 After this PR is merged. $ ls -1
AppName
appname-2
appname-3 type $ ls appName
> appName█
0/3 (0) |
@zydou You can add |
@Aloxaf Could you elaborate a little more? I added |
Same issue here. |
@LinoWhy Hi, I just pinned the version to 02ce77cc855db31fabe0f98181078f3ced0b7b70. This is the last commit that works with the same word in different cases. |
It might be beneficial to create a new Issue for this. And by mentioning it here, you can ensure it doesn't get overlooked. |
@LinoWhy Thanks a lot! I can confirm |
This PR is another approch to let fzf-tab complete the common prefix.
It can handle some corner cases like #384 (comment) and zsh-z.
how to enable
known bugs
It breaks multiple selectionsrelated issues/pr
#8 #384