-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
117 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,86 @@ | ||
Setup: | ||
```zsh | ||
% zmodload zsh/param/private | ||
% autoload -Uz zmathfunc && zmathfunc | ||
% autoload -Uz $PWD/functions/widget/.autocomplete.complete-word.post | ||
% unset terminfo | ||
% typeset -gA terminfo=() compstate=( old_list shown ) _lastcomp=() | ||
% terminfo[kcbt]=BACKSPACE | ||
% typeset -gA compstate=() _lastcomp=() terminfo=() | ||
% zstyle ':autocomplete:*' add-space 'FOO' 'TAG' 'BAR' | ||
% zstyle ':autocomplete:(|shift-)tab:' widget-style complete-word | ||
% KEYS=$'\t' WIDGET=complete-word terminfo[kcbt]=BACKTAB | ||
% compstate[old_list]=keep compstate[nmatches]=0 _lastcomp[nmatches]=2 | ||
% | ||
``` | ||
|
||
Only `menu-select` widget sets `$MENUSELECT`: | ||
If we have only 1 match, just insert it: | ||
```zsh | ||
% WIDGET=menu-select .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} ${(q+)compstate[list]} $+MENUSELECT | ||
1 '' 1 | ||
% _lastcomp[nmatches]=1 | ||
% .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} $+compstate[list] $+MENUSELECT | ||
1 0 0 | ||
% _lastcomp[nmatches]=2 | ||
% | ||
``` | ||
|
||
Only `Shift-Tab` key sets `$compstate[insert]` to `*:0`: | ||
If we have more than 1 match, but there's no old list, then show the list and don't insert: | ||
```zsh | ||
% KEYS=BACKSPACE .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} ${(q+)compstate[list]} $+MENUSELECT | ||
0 '' 0 | ||
% compstate[old_list]= compstate[nmatches]=2 | ||
% .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} $+compstate[list] $+MENUSELECT | ||
'' 1 0 | ||
% compstate[old_list]=keep compstate[nmatches]=0 | ||
% | ||
``` | ||
|
||
`add-space` tag in current completion adds space: | ||
`menu-*` widgets set `$compstate[insert]` to `menu:*`: | ||
```zsh | ||
% _comp_tags='LOREM TAG IPSUM' _lastcomp[tags]='OTHER' .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} ${(q+)compstate[list]} $+MENUSELECT | ||
'1 ' '' 0 | ||
% zstyle ':autocomplete:shift-tab:' widget-style reverse-menu-complete | ||
% KEYS=$terminfo[kcbt] | ||
% .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} $+compstate[list] $+MENUSELECT | ||
menu:0 0 0 | ||
% zstyle ':autocomplete:shift-tab:' widget-style complete-word | ||
% KEYS=$'\t' | ||
% | ||
``` | ||
|
||
`add-space` tag in previous completion adds space, if current completion is not used: | ||
Widgets default to `menu-select`, which sets `$MENUSELECT`, even without old list: | ||
```zsh | ||
% _comp_tags= _lastcomp[tags]='LOREM TAG IPSUM' .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} ${(q+)compstate[list]} $+MENUSELECT | ||
'1 ' '' 0 | ||
% KEYS=OTHER compstate[old_list]= compstate[nmatches]=2 | ||
% .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} $+compstate[list] $+MENUSELECT | ||
menu:1 0 1 | ||
% KEYS=$'\t' compstate[old_list]=keep compstate[nmatches]=0 | ||
% | ||
``` | ||
|
||
`add-space` tag in previous completion does NOT add space, if current completion is used: | ||
`Shift-Tab` key sets `$compstate[insert]` to `*0`: | ||
```zsh | ||
% _comp_tags='OTHER' _lastcomp[tags]='TAG' .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} ${(q+)compstate[list]} $+MENUSELECT | ||
1 '' 0 | ||
% KEYS=$terminfo[kcbt] | ||
% .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} $+compstate[list] $+MENUSELECT | ||
0 0 0 | ||
% KEYS=$'\t' | ||
% | ||
``` | ||
|
||
If list is not yet shown, then insert unambiguous and show list: | ||
If the list is showing and there's an `add-space` tag in the last completion, then add a space: | ||
```zsh | ||
% compstate[old_list]= _comp_tags= _lastcomp[tags]= .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} ${(q+)compstate[list]} $+MENUSELECT | ||
unambiguous 'list force packed rows' 0 | ||
# % functions -T .autocomplete.complete-word.post | ||
% _comp_tags='OTHER' _lastcomp[tags]='LOREM TAG IPSUM' | ||
% .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} $+compstate[list] $+MENUSELECT | ||
'1 ' 0 0 | ||
% compstate[old_list]= _lastcomp[tags]= | ||
% | ||
``` | ||
|
||
If the list is not showing and there's an `add-space` tag in the new completion, then add a space: | ||
```zsh | ||
% compstate[old_list]= _comp_tags='LOREM TAG IPSUM' _lastcomp[tags]='OTHER' | ||
% .autocomplete.complete-word.post | ||
% print -r -- ${(q+)compstate[insert]} $+compstate[list] $+MENUSELECT | ||
'1 ' 0 0 | ||
% compstate[old_list]=keep _comp_tags= _lastcomp[tags]= | ||
% | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7b1a81c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Marlon,
autocomplete on my m1 macbook breaks when I update to this commit or beyond.
I have to revert to an older commit to get the widget back.
For example, when I try to cd to a dir I get this:
I'm not sure how to continue from here, but I've managed to pinpoint the commit where it breaks.
7b1a81c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmhj Please open a bug report.