From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Completion in empty double-quotes generates error
Date: Sat, 2 Apr 2016 11:18:15 -0700 [thread overview]
Message-ID: <160402111815.ZM1925@torch.brasslantern.com> (raw)
In-Reply-To: <160401232021.ZM25900@torch.brasslantern.com>
On Apr 1, 11:20pm, Bart Schaefer wrote:
} Subject: Re: Completion in empty double-quotes generates error
}
} In the redirection 2>1, gotword() has concluded that the word to be
} completed is "1" rather than (a prefix of) "2".
}
} This is probably because the lexer wants to treat "2>" as a single
} token
Indeed, zshlex() consumes "2>" as a single OUTANG token with tokfd = 2
handled as metadata.
This means that in "2>1" the only complete-able "word" that the lexer
recognizes on the line is the "1" following the redirection.
What would one expect to be completed with the cursor on the "2"? The
-redirect- special context is for what comes *after* the operator. I
can think of only two choices:
1. Complete as if there were an implicit space to the right of the
cursor. This makes some sense because "2>" is treated as the same
single token as ">" all alone.
2. Treat it as an error and simply fail.
Patch below does this, but it ought to also insert a space to the right
of any inserted word, which I haven't done yet. If someone else knows
how to do that, please jump in.
As a bonus, this patch fixes a case where wordpos was incorrectly left
at 1 near a redirection, causing command completion to incorrectly be
invoked.
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index a89b2a3..553721c 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -1238,6 +1238,15 @@ get_comp_string(void)
/* Record if we haven't had the command word yet */
if (wordpos == redirpos)
redirpos++;
+ if (zlemetacs < (zlemetall - inbufct)) {
+ /* Cursor is in the middle of a redirection, treat as a word */
+ DPUTS3(addedx,
+ "added x in redirect: wb = %d, we = %d, zlemetacs = %d",
+ wb, we, zlemetacs);
+ wb = zlemetacs;
+ we = zlemetall - inbufct;
+ wordpos++;
+ }
}
if (tok == DINPAR)
tokstr = NULL;
next prev parent reply other threads:[~2016-04-02 18:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 18:06 Bart Schaefer
2016-04-01 5:36 ` Daniel Shahaf
2016-04-02 1:18 ` Bart Schaefer
2016-04-02 3:29 ` Daniel Shahaf
2016-04-02 6:20 ` Bart Schaefer
2016-04-02 18:18 ` Bart Schaefer [this message]
2016-04-06 19:10 ` Bart Schaefer
2016-05-10 18:40 ` Daniel Shahaf
2016-05-10 20:13 ` Bart Schaefer
2016-05-10 21:00 ` Bart Schaefer
2016-05-11 16:21 ` Daniel Shahaf
2016-05-10 21:29 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=160402111815.ZM1925@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).