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

Re: completion after < at the start of the line

Stephane Chazelas <Stephane_Chazelas@xxxxxxxx> wrote:
> $ mkdir 1
> $ cd 1
> $ touch foo bar
> $ zsh -f
> sc% < b<TAB> foo
> (That is type "< b foo" move the cursor back to 4rd character,
> then type <Tab>)
> Then zsh completes that to:
> sc% < foo foo
> (instead of expected < bar foo).

Good news:  I know why this happens.  Bad news: it's in get_comp_string(),
one of the world's most impenetrable functions (but you should see

We reset the index into the completion words to zero when the command word
arrives.  Obviously this is wrong in this case since the argument to the
redirection is already there and this overwrites it.  However, not setting it to zero at that point is too simple a fix since it messes up handling of multiple commands on a line separated by ";" etc. etc.

Unfortunately the handling of the index into the array of words is obscured
by one of those typical variables (here called "ins") which gets set to
apparently random values in random places in the function, is used in tests
all over the place so you're never quite sure what's going on, and is
completely undocumented.  If we could work out that was doing (and,
ideally, document it, although I'm not sure the words don't magically drift
off the editor into space if you try) we might be able to work out how to
reset the start of line index.

An alternative strategy is to record redirections before the command word,
but I'd rather understand what's there at present than bolt something new
on regardless.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview

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