* [PATCH] another fix for 'compset -q'
@ 2018-05-28 12:42 Jun T.
0 siblings, 0 replies; only message in thread
From: Jun T. @ 2018-05-28 12:42 UTC (permalink / raw)
To: zsh-workers
Another minor "improvement" of 'compset -q'
It just avoids the warning in the example below; you can't get
any useful completion either with or without the patch.
zsh% zsh -c 'for (( i = 0;<TAB>
5: compcore.c:1676: expecting 'x' at offset 6 of "i = 0"
The cursor 'x' is not in the current word "i = 0" but in the
next token. This indicates the function gotword() (lex.c)
resets lexflags to 0 too early. I guess the global variable
zlemetall (which is used in gotword()) need not count the 'x'
added at the cursor, because get_cmp_string() (zle_tricky.c)
also adds 'x' at the cursor by using addx() but does not
increment zlemetall.
It seems gotword() takes account of addedx by itself.
If zlemetall is decremented by 1 (= addedx), then the
wb and we returned by gotword() also decrease. So we
need the 2nd hunk.
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index f733e0ee5..fd415da89 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1610,9 +1610,11 @@ set_comp_sep(void)
inpush(dupstrspace(tmp), 0, NULL);
zlemetaline = tmp;
/*
- * Length of temporary string, calculated above.
+ * tl is the length of temporary string, calculated above.
+ * It seems zlemetall need not include the 'x' added at the cursor.
+ * addedx is taken care of in function gotword() (lex.c).
*/
- zlemetall = tl;
+ zlemetall = tl - addedx;
strinbeg(0);
noaliases = 1;
do {
@@ -1668,8 +1670,8 @@ set_comp_sep(void)
DPUTS(!p, "no current word in substr");
got = 1;
cur = countlinknodes(foo) - 1; /* cur is 0 offset */
- swb = wb - 1 - dq - sq - dolq;
- swe = we - 1 - dq - sq - dolq;
+ swb = wb - dq - sq - dolq;
+ swe = we - dq - sq - dolq;
sqq = lsq;
soffs = zlemetacs - swb - css;
DPUTS2(p[soffs] != 'x', "expecting 'x' at offset %d of \"%s\"",
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-28 12:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-28 12:42 [PATCH] another fix for 'compset -q' Jun T.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).