diff options
author | Barton E. Schaefer <schaefer@zsh.org> | 2016-04-07 20:24:43 -0700 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2016-04-07 20:24:43 -0700 |
commit | b9113980642f37d780d646fcbf4ef90dca69ae3f (patch) | |
tree | a9f950dfeb33f03a66d978c2fe20dcd47c082263 /Src/Zle | |
parent | 70fb93b64ef68457f5ca2bb6b68cf2e59ec7287c (diff) | |
download | zsh-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/Zle')
-rw-r--r-- | Src/Zle/zle_tricky.c | 15 |
1 files changed, 15 insertions, 0 deletions
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; |