diff src/edit.c @ 23076:5fbac68bda23 v8.2.2084

patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character Commit: https://github.com/vim/vim/commit/0684e36a7ee0743f2889698fb8e0e14f7acae423 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 3 19:54:42 2020 +0100 patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character Problem: CTRL-V U doesn't work to enter a Unicode character when modifyOtherKeys is effective. (Ken Takata) Solution: Add a flag to get_literal() for the shift key. (closes #7413)
author Bram Moolenaar <Bram@vim.org>
date Thu, 03 Dec 2020 20:00:05 +0100
parents be7f52838056
children aa8fa32cdca3
line wrap: on
line diff
--- a/src/edit.c
+++ b/src/edit.c
@@ -1534,7 +1534,6 @@ ins_ctrl_v(void)
 {
     int		c;
     int		did_putchar = FALSE;
-    int		prev_mod_mask = mod_mask;
 
     // may need to redraw when no more chars available now
     ins_redraw(FALSE);
@@ -1550,7 +1549,9 @@ ins_ctrl_v(void)
     add_to_showcmd_c(Ctrl_V);
 #endif
 
-    c = get_literal();
+    // Do not change any modifyOtherKeys ESC sequence to a normal key for
+    // CTRL-SHIFT-V.
+    c = get_literal(mod_mask & MOD_MASK_SHIFT);
     if (did_putchar)
 	// when the line fits in 'columns' the '^' is at the start of the next
 	// line and will not removed by the redraw
@@ -1559,11 +1560,6 @@ ins_ctrl_v(void)
     clear_showcmd();
 #endif
 
-    if ((c == ESC || c == CSI) && !(prev_mod_mask & MOD_MASK_SHIFT))
-	// Using CTRL-V: Change any modifyOtherKeys ESC sequence to a normal
-	// key.  Don't do this for CTRL-SHIFT-V.
-	c = decodeModifyOtherKeys(c);
-
     insert_special(c, FALSE, TRUE);
 #ifdef FEAT_RIGHTLEFT
     revins_chars++;
@@ -1845,9 +1841,11 @@ del_char_after_col(int limit_col UNUSED)
  * A one, two or three digit decimal number is interpreted as its byte value.
  * If one or two digits are entered, the next character is given to vungetc().
  * For Unicode a character > 255 may be returned.
+ * If "noReduceKeys" is TRUE do not change any modifyOtherKeys ESC sequence
+ * into a normal key, return ESC.
  */
     int
-get_literal(void)
+get_literal(int noReduceKeys)
 {
     int		cc;
     int		nc;
@@ -1878,6 +1876,9 @@ get_literal(void)
     for (;;)
     {
 	nc = plain_vgetc();
+	if ((nc == ESC || nc == CSI) && !noReduceKeys)
+	    nc = decodeModifyOtherKeys(nc);
+
 #ifdef FEAT_CMDL_INFO
 	if (!(State & CMDLINE) && MB_BYTE2LEN_CHECK(nc) == 1)
 	    add_to_showcmd(nc);
@@ -3812,8 +3813,7 @@ ins_ctrl_o(void)
 {
     if (State & VREPLACE_FLAG)
 	restart_edit = 'V';
-    else
-	if (State & REPLACE_FLAG)
+    else if (State & REPLACE_FLAG)
 	restart_edit = 'R';
     else
 	restart_edit = 'I';