diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/zle_tricky.c | 15 | ||||
-rw-r--r-- | Src/lex.c | 10 |
2 files changed, 22 insertions, 3 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; 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; } } |