From b9113980642f37d780d646fcbf4ef90dca69ae3f Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Thu, 7 Apr 2016 20:24:43 -0700 Subject: 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. --- Src/Zle/zle_tricky.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Src/Zle') diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index b1709c117..1d4e1d284 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -1161,6 +1161,7 @@ get_comp_string(void) inpush(dupstrspace(linptr), 0, NULL); strinbeg(0); wordpos = cp = rd = ins = oins = linarr = parct = ia = redirpos = 0; + we = wb = zlemetacs; tt0 = NULLTOK; /* This loop is possibly the wrong way to do this. It goes through * @@ -1238,6 +1239,20 @@ get_comp_string(void) /* Record if we haven't had the command word yet */ if (wordpos == redirpos) redirpos++; + if (zlemetacs < (zlemetall - inbufct) && + zlemetacs >= wordbeg && wb == we) { + /* Cursor is in the middle of a redirection, treat as a word */ + we = zlemetall - (inbufct + addedx); + if (addedx && we > wb) { + /* Assume we are in {param}> form, wb points at "{" */ + wb++; + /* Should complete parameter names here */ + } else { + /* In "2>" form, zlemetacs points at "2" */ + wb = zlemetacs; + /* Should insert a space under cursor here */ + } + } } if (tok == DINPAR) tokstr = NULL; -- cgit 1.4.1