Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: resent: pws-22: hash key completion in brackets



Andrej Borsenkow wrote:

> bor@itsrm2:~%> unset foo[ba<TAB>]
> Beep

Yes, wrong test for the closing bracket in get_comp_string().

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Thu Jun 17 09:24:31 1999
+++ Src/Zle/zle_tricky.c	Thu Jun 17 11:04:37 1999
@@ -1484,11 +1484,14 @@
 			if (lev)
 			    lev--;
 		    }
-		wb++;
 		p = (char *) line + wb;
+		wb++;
 		if (wb && (*p == '[' || *p == '(') &&
-		    !skipparens(*p, (*p == '[' ? ']' : ')'), &p))
-			we = p - (char *) line;
+		    !skipparens(*p, (*p == '[' ? ']' : ')'), &p)) {
+			we = (p - (char *) line) - 1;
+			if (insubscr == 2)
+			    insubscr = 3;
+		}
 	    } else {
 		/* In mathematical expression, we complete parameter names  *
 		 * (even if they don't have a `$' in front of them).  So we *
@@ -1513,9 +1516,10 @@
 		varname = ztrdup((char *) line + i + 1);
 		line[wb - 1] = sav;
 		if ((keypm = (Param) paramtab->getnode(paramtab, varname)) &&
-		    (keypm->flags & PM_HASHED))
-		    insubscr = 2;
-		else
+		    (keypm->flags & PM_HASHED)) {
+		    if (insubscr != 3)
+			insubscr = 2;
+		} else
 		    insubscr = 1;
 	    }
 	}
@@ -5281,10 +5285,10 @@
         cc = &cc_default;
 	keypm = NULL;
     } else if (linwhat == IN_MATH) {
-	if (insubscr == 2) {
+	if (insubscr >= 2) {
 	    /* Inside subscript of assoc array, complete keys. */
 	    cc_dummy.mask = 0;
-	    cc_dummy.suffix = "]";
+	    cc_dummy.suffix = (insubscr == 2 ? "]" : "");
 	} else {
 	    /* Other math environment, complete paramete names. */
 	    keypm = NULL;
diff -u oc/Base/_subscript Completion/Base/_subscript
--- oc/Base/_subscript	Thu Jun 17 09:24:53 1999
+++ Completion/Base/_subscript	Thu Jun 17 11:15:19 1999
@@ -1,7 +1,11 @@
 #compdef -subscript-
 
 if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
-  compadd -S ']' - "${(@kP)${compstate[parameter]}}"
+  if [[ "$RBUFFER" = \]* ]]; then
+    compadd -S '' - "${(@kP)${compstate[parameter]}}"
+  else
+    compadd -S ']' - "${(@kP)${compstate[parameter]}}"
+  fi
 else
   _compalso -math-
 fi

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author