about summary refs log tree commit diff
path: root/Src/lex.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-04-07 20:24:43 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-04-07 20:24:43 -0700
commitb9113980642f37d780d646fcbf4ef90dca69ae3f (patch)
treea9f950dfeb33f03a66d978c2fe20dcd47c082263 /Src/lex.c
parent70fb93b64ef68457f5ca2bb6b68cf2e59ec7287c (diff)
downloadzsh-b9113980642f37d780d646fcbf4ef90dca69ae3f.tar.gz
zsh-b9113980642f37d780d646fcbf4ef90dca69ae3f.tar.xz
zsh-b9113980642f37d780d646fcbf4ef90dca69ae3f.zip
38248: fix word position calculation when completing on or just before a redirection operator
The completion result is still in need of some repair; e.g., if the first
thing on the line is the redirection, completion before it is not taken
to be in command position, and in this and other cases a necessary space
is not inserted between the completed word and the redirection.
Diffstat (limited to 'Src/lex.c')
-rw-r--r--Src/lex.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Src/lex.c b/Src/lex.c
index d4132fe76..25b372a3c 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1789,9 +1789,13 @@ parse_subst_string(char *s)
 static void
 gotword(void)
 {
-    we = zlemetall + 1 - inbufct + (addedx == 2 ? 1 : 0);
-    if (zlemetacs <= we) {
-	wb = zlemetall - wordbeg + addedx;
+    int nwe = zlemetall + 1 - inbufct + (addedx == 2 ? 1 : 0);
+    if (zlemetacs <= nwe) {
+	int nwb = zlemetall - wordbeg + addedx;
+	if (zlemetacs >= nwb) {
+	    wb = nwb;
+	    we = nwe;
+	}
 	lexflags = 0;
     }
 }