Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug in 3.1.4 completion

greg@xxxxxxxxxxxxx wrote:

> Hi,
> I have found a minor bug in zsh 3.1.4 completion related to the
> automagic removal of completed slashes.  If I invoke zsh -f, 
> % mkdir test
> % cd test
> % mkdir foo
> % mkdir foo/bar foo/barbaz
> % ls f               ; now type TAB
>   -> foo/            ; now type TAB
>   -> foo/bar         ; now type SPACE
>   -> foo/ba          ; notice the "r" got removed.
> This only seems to happen if you complete "foo" then
> immediately hit TAB again.  If you type part of "bar" and
> then TAB it functions correctly.

There was a missing fixsuffix() when inserting the unambiguous string
for normal completion. It's fixed by the second hunk in the patch
below (this is for 3.1.5, but you can easily insert the call to
fixsuffix() in 3.1.4 in do_ambiguous() in the else-branch of the `if(p)').

> While I'm at it I have a few other nits about the completion system
> (which on the whole I think is excellent).
> First, another somewhat inconvenient behavior related to slash removal
> (again zsh -f, and with the same directories created above):
> % ls fo bar      ; position the cursor on the space after the "o", hit TAB
>   -> foo/ bar    ; now, the cursor is still on the space after the "/".
>                  ; hit Control-d to delete the space 
>   -> foo/bar     ; with cursor on "b".  now Control-e (end-of-line) and
>   -> foobar      ; the "/" gets removed.  ugh.

Here is another missing call to fixsuffix() (fixed by the first
hunk). This one goes into deletecharorlist() which has to do the
itself since the calling code doesn't call fixsuffix() since it may
use the completion code.

> Another behavior that's not quite right IMHO is completeinword:
> % setopt noalwaystoend completeinword
> % ls fo/bar         ; position cursor on "/", hit TAB
>   -> foo/bar/       ; hit TAB again
>   -> foo/bar//      ; hit TAB again
>   -> foo/bar///     ; etc, never listing possible completions
> Even if I move past the "/", or even "b" it never jumps to the end of
> "bar".

This is fixed in 3.1.5 with my last patches.

> Setting alwaystoend helps, though it is still very picky about
> the stuff on both sides matching, which often makes the feature
> useless.  I have modified emacs to do what I believe is the right
> thing:
>    * look for completions using both text on left and right.
>      if there are none, look only for completions from the left.  this 
>      way having some garbage on the right doesn't hose you, it just
>      gets pushed right (it may match later, after more completing).
>    * now, insert the completed text, placing cursor at the end of the
>      insertion.
>    * remove the longest substring to the right (with start anchored at
>      the cursor) which matches a substring to the left (with end
>      anchored at the cursor).  there may be none.
> How hard would it be to add this to zsh?

That would be expand-or-complete-prefix with a little hacking (the remove-
the-matched-prefix-of-the-suffix part), not too hard.

> While I'm on little nits, it would be nice if the FIGNORE variable
> were not used when listing completions:
> % FIGNORE='.o'
> % touch foo.o foo.c
> % ls fo      ; type Control-d to list completions, you only see "foo.c"

I'm not too sure about this one, since C-d should list the completions 
and if there are other matching files the ignored ones aren't
completions. If there are no other files fignore will be ignored and
the files will be listed. I could be convinced to list the ignored
files separately (this indeed may make sense).

> One last feature that'd be nice is automatic case conversion.  When
> completing, if no completions are found, try again for a case
> insensitive completion.  Would this be easy to add?

We got many requests for this. For 3.1.5 there is a proposed patch
that adds a generic way to control the matching behavior of
completion. With this you can get case-insensitive completion, partial 
word completion and several other things.


diff -c os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
*** os/Zle/zle_tricky.c	Wed Nov  4 08:57:00 1998
--- Src/Zle/zle_tricky.c	Wed Nov  4 09:17:18 1998
*** 309,316 ****
      usemenu = isset(MENUCOMPLETE);
      useglob = isset(GLOBCOMPLETE);
!     if (cs != ll)
--- 309,318 ----
      usemenu = isset(MENUCOMPLETE);
      useglob = isset(GLOBCOMPLETE);
!     if (cs != ll) {
! 	fixsuffix();
+     }
*** 4789,4794 ****
--- 4791,4798 ----
  	int ics = cs, ocs, pl = 0, l, lp, ls;
  	char *ps;
  	Cline lc;
+ 	fixsuffix();
  	/* Delete the old stuff from the command line. */
  	cs = wb;

Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx

Messages sorted by: Reverse Date, Date, Thread, Author