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

Re: Zsh Bug Report: vi mode inner motions diw and ciw incorrect



On Thu, 1 Jun 2017 13:19:02 +0000
John Kaczor <johnkaczor@xxxxxxxxxxx> wrote:
> bindkey -M viopp iw
> Outputs
> "iw" select-in-word
> 
> I cut down my zshrc to a minimal version that reproduces the issue.
> It appears to only occur once I have sourced
> zsh-history-substring-search.zsh. I cloned the latest version of this
> plugin.  Also, zsh 5.0.8 works as expected even when sourcing
> zsh-history-substring-search.zsh, but zsh 5.3.1 does not.

I don't know that function or where it comes from, but I can see one
problem that's going to make things difficulty, namely it doesn't test
for the equivalent "immortal" binding.

(FAOD: this new test isn't needed for t_undefinedkey which is passed
around specially internally.)

pws

diff --git a/Completion/Unix/Command/_sudo b/Completion/Unix/Command/_sudo
index aa7a1a4..0b09ded 100644
--- a/Completion/Unix/Command/_sudo
+++ b/Completion/Unix/Command/_sudo
@@ -41,6 +41,8 @@ if [[ $service = sudoedit ]] || (( $words[(i)-e] < $words[(i)^(*sudo|-[^-]*)] ))
   args=( -A "-*" $args '!(-V --version -h --help)-e' '*:file:_files' )
 else
   cmd="$words[1]"
+  local ext
+  (( ${words[(I)-[is]]} == 0 )) && ext=" -e"
   args+=(
     '(-e --edit 1 *)'{-e,--edit}'[edit files instead of running a command]' \
     '(-s --shell)'{-s,--shell}'[run shell as the target user; a command may also be specified]' \
@@ -49,7 +51,7 @@ else
     '(-E --preserve-env -i --login -s --shell -e --edit)'{-E,--preserve-env}'[preserve user environment when running command]' \
     '(-H --set-home -i --login -s --shell -e --edit)'{-H,--set-home}"[set HOME variable to target user's home dir]" \
     '(-P --preserve-groups -i -login -s --shell -e --edit)'{-P,--preserve-groups}"[preserve group vector instead of setting to target's]" \
-    '(-)1:command: _command_names -e'
+    "(-)1:command: _command_names$ext"
     '*::arguments:{ _comp_priv_prefix=( $cmd -n ${(kv)opt_args[(I)(-[ugHEP]|--(user|group|set-home|preserve-env|preserve-groups))]} ) ; _normal }'
   )
 fi
diff --git a/Src/Zle/textobjects.c b/Src/Zle/textobjects.c
index 3db0781..bf83906 100644
--- a/Src/Zle/textobjects.c
+++ b/Src/Zle/textobjects.c
@@ -48,9 +48,10 @@ int
 selectword(UNUSED(char **args))
 {
     int n = zmult;
-    int all = (bindk == t_selectaword || bindk == t_selectablankword);
-    int (*viclass)(ZLE_CHAR_T) = (bindk == t_selectaword ||
-	    bindk == t_selectinword) ? wordclass : blankwordclass;
+    int all = IS_THINGY(bindk, selectaword) ||
+	IS_THINGY(bindk, selectablankword);
+    int (*viclass)(ZLE_CHAR_T) = (IS_THINGY(bindk, selectaword) ||
+	    IS_THINGY(bindk, selectinword)) ? wordclass : blankwordclass;
     int sclass = viclass(zleline[zlecs]);
     int doblanks = all && sclass;
 
@@ -288,7 +289,7 @@ selectargument(UNUSED(char **args))
     free(stringaszleline(linein, wstarts[wcur], &zlecs, &tmpsz, &mark));
     free(linein);
 
-    if (bindk == t_selectinshellword) {
+    if (IS_THINGY(bindk, selectinshellword)) {
 	ZLE_CHAR_T *match = ZWS("`\'\"");
 	ZLE_CHAR_T *lmatch = ZWS("\'({"), *rmatch = ZWS("\')}");
 	ZLE_CHAR_T *ematch = match, *found;
diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h
index 8f92e56..07b3101 100644
--- a/Src/Zle/zle.h
+++ b/Src/Zle/zle.h
@@ -230,6 +230,13 @@ struct thingy {
 /* DISABLED is (1<<0) */
 #define TH_IMMORTAL	(1<<1)    /* can't refer to a different widget */
 
+/*
+ * Check if bindk refers to named thingy (a set of bare characters),
+ * also checking the special .thingy widget.
+ */
+#define IS_THINGY(bindk, name)				\
+    ((bindk) == t_ ## name || (bindk) == t_D ## name)
+
 /* command modifier prefixes */
 
 struct modifier {
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 04eb706..2e96ac7 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -961,7 +961,7 @@ bin_bindkey_meta(char *name, char *kmname, Keymap km, UNUSED(char **argv), UNUSE
 	    m[0] = i;
 	    metafy(m, 1, META_NOALLOC);
 	    fn = keybind(km, m, &str);
-	    if(fn == t_selfinsert || fn == t_undefinedkey)
+	    if(IS_THINGY(fn, selfinsert) || fn == t_undefinedkey)
 		bindkey(km, m, refthingy(Th(metabind[i - 128])), NULL);
 	}
     return 0;



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