patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Problem: Other text for CTRL-V in Insert mode with modifyOtherKeys.
Solution: Convert the Escape sequence back to key as if modifyOtherKeys is
not set, and use CTRL-SHIFT-V to get the Escape sequence itself.
(closes #5254)
diff --git a/src/getchar.c b/src/getchar.c
index b086126..a3af879 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1525,6 +1525,38 @@
}
/*
+ * Convert "c" plus "mod_mask" to merge the effect of modifyOtherKeys into the
+ * character.
+ */
+ int
+merge_modifyOtherKeys(int c_arg)
+{
+ int c = c_arg;
+
+ if (mod_mask & MOD_MASK_CTRL)
+ {
+ if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_'))
+ {
+ c &= 0x1f;
+ mod_mask &= ~MOD_MASK_CTRL;
+ }
+ else if (c == '6')
+ {
+ // CTRL-6 is equivalent to CTRL-^
+ c = 0x1e;
+ mod_mask &= ~MOD_MASK_CTRL;
+ }
+ }
+ if ((mod_mask & (MOD_MASK_META | MOD_MASK_ALT))
+ && c >= 0 && c <= 127)
+ {
+ c += 0x80;
+ mod_mask &= ~(MOD_MASK_META|MOD_MASK_ALT);
+ }
+ return c;
+}
+
+/*
* Get the next input character.
* Can return a special key or a multi-byte character.
* Can return NUL when called recursively, use safe_vgetc() if that's not
@@ -1765,30 +1797,9 @@
}
if (!no_reduce_keys)
- {
// A modifier was not used for a mapping, apply it to ASCII
// keys. Shift would already have been applied.
- if (mod_mask & MOD_MASK_CTRL)
- {
- if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_'))
- {
- c &= 0x1f;
- mod_mask &= ~MOD_MASK_CTRL;
- }
- else if (c == '6')
- {
- // CTRL-6 is equivalent to CTRL-^
- c = 0x1e;
- mod_mask &= ~MOD_MASK_CTRL;
- }
- }
- if ((mod_mask & (MOD_MASK_META | MOD_MASK_ALT))
- && c >= 0 && c <= 127)
- {
- c += 0x80;
- mod_mask &= ~(MOD_MASK_META|MOD_MASK_ALT);
- }
- }
+ c = merge_modifyOtherKeys(c);
break;
}