Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion in empty double-quotes generates error
- X-seq: zsh-workers 38232
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Completion in empty double-quotes generates error
- Date: Sat, 2 Apr 2016 11:18:15 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=1NDaoTIr5U5f357TI6FFkNBd8Y/eXRvGmAp7Xn0yprY=; b=D8It8JOe5gTa5IBgDiekhAY5FmD+j36GLDi8iaW9bgUq9HLy0ubL+PNR7RNEDvQ+OW zFRwiRD/qYrH+CbLOXO8onUN/wLAjspsaFr3aDUO8oP9HmFfLxuXP8YjSx9x9GzBh5aQ DWtinnox/eVGuXG0OGse6mxeyk+GJESyIwPRIEfEaRFudN4ZLZM3uIyJDrEevuxbVQc0 m4nUjdcDB3rbKLjhiwGJKsY9SkiqfLFdHyhGqTnyUVivdGQkU39KPdviBNNObJCNQM5H FPMGre5QXTyxJIhudFAz3+RD8Eeg/Mag8r0/opvJOhTl1H0TAr00bi8jdyRvxhLUNC9l /+6w==
- In-reply-to: <160401232021.ZM25900@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <160330110652.ZM1432@torch.brasslantern.com> <20160401053633.GA17993@tarsus.local2> <160401181824.ZM23675@torch.brasslantern.com> <20160402032950.GA10638@tarsus.local2> <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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author