changeset 36254:0d49cfca0d23 draft v9.1.0762

patch 9.1.0762: 'cedit', 'termwinkey' and 'wildchar' may not be parsed correctly Commit: https://github.com/vim/vim/commit/a9c6f90918d0012d1b8c8c5c1dccb77407f553fb Author: Milly <milly.ca@gmail.com> Date: Sun Oct 6 16:47:02 2024 +0200 patch 9.1.0762: 'cedit', 'termwinkey' and 'wildchar' may not be parsed correctly Problem: 'cedit', 'termwinkey' and 'wildchar' may not be parsed correctly Solution: improve string_to_key() function in option.c (Milly) - Problem: `^@` raises an error. Solution: Store as `<Nul>`. - Problem: `<t_xx` does not raise an error. Solution: Raise an error if closing `>` is missing. - Problem: Single `<` or `^` raises an error. It is inconvenient for users. Solution: They are stored as a single character. closes: #15811 Signed-off-by: Milly <milly.ca@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 06 Oct 2024 17:00:06 +0200
parents a025e6f8377b
children 5cb68a77256c
files runtime/doc/options.txt src/option.c src/testdir/gen_opt_test.vim src/version.c
diffstat 4 files changed, 35 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*	For Vim version 9.1.  Last change: 2024 Oct 02
+*options.txt*	For Vim version 9.1.  Last change: 2024 Oct 06
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -8432,8 +8432,11 @@ A jump table for the options with a shor
 			local to window
 	The key that starts a CTRL-W command in a terminal window.  Other keys
 	are sent to the job running in the window.
-	The <> notation can be used, e.g.: >
-		:set termwinkey=<C-L>
+	The key can be specified as a single character, a |key-notation| (e.g.
+	<Up>, <C-F>) or a letter preceded with a caret (e.g. `^F` is CTRL-F): >
+		:set twk=X
+		:set twk=^I
+		:set twk=<C-L>
 <	The string must be one key stroke but can be multiple bytes.
 	When not set CTRL-W is used, so that CTRL-W : gets you to the command
 	line.  If 'termwinkey' is set to CTRL-L then CTRL-L : gets you to the
@@ -9330,7 +9333,12 @@ A jump table for the options with a shor
 	Some keys will not work, such as CTRL-C, <CR> and Enter.
 	<Esc> can be used, but hitting it twice in a row will still exit
 	command-line as a failsafe measure.
-	Although 'wc' is a number option, you can set it to a special key: >
+	Although 'wc' is a number option, it can be specified as a number, a
+	single character, a |key-notation| (e.g. <Up>, <C-F>) or a letter
+	preceded with a caret (e.g. `^F` is CTRL-F): >
+		:set wc=27
+		:set wc=X
+		:set wc=^I
 		:set wc=<Tab>
 <	NOTE: This option is set to the Vi default value when 'compatible' is
 	set and to the Vim default value when 'compatible' is reset.
--- a/src/option.c
+++ b/src/option.c
@@ -2794,16 +2794,21 @@ did_set_option(
 
 /*
  * Convert a key name or string into a key value.
- * Used for 'wildchar' and 'cedit' options.
+ * Used for 'cedit', 'termwinkey', 'wildchar' and 'wildcharm' options.
  * When "multi_byte" is TRUE allow for multi-byte characters.
  */
     int
 string_to_key(char_u *arg, int multi_byte)
 {
-    if (*arg == '<')
+    if (*arg == '<' && arg[1])
 	return find_key_option(arg + 1, TRUE);
-    if (*arg == '^')
-	return Ctrl_chr(arg[1]);
+    if (*arg == '^' && arg[1])
+    {
+	int key = Ctrl_chr(arg[1]);
+	if (key == 0)		// ^@ is <Nul>
+	    key = K_ZERO;
+	return key;
+    }
     if (multi_byte)
 	return PTR2CHAR(arg);
     return *arg;
@@ -5622,7 +5627,10 @@ find_key_option(char_u *arg_arg, int has
     // Don't use get_special_key_code() for t_xx, we don't want it to call
     // add_termcap_entry().
     if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
-	key = TERMCAP2KEY(arg[2], arg[3]);
+    {
+	if (!has_lt || arg[4] == '>')
+	    key = TERMCAP2KEY(arg[2], arg[3]);
+    }
     else if (has_lt)
     {
 	--arg;			    // put arg at the '<'
--- a/src/testdir/gen_opt_test.vim
+++ b/src/testdir/gen_opt_test.vim
@@ -59,10 +59,10 @@ let test_values = {
       \ 'updatecount': [[0, 1, 8, 9999], [-1]],
       \ 'updatetime': [[0, 1, 8, 9999], [-1]],
       \ 'verbose': [[-1, 0, 1, 8, 9999], []],
-      \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '<Esc>', '<t_xx>'],
-      \		['', 'xxx', '<xxx>', '<Esc', '<C-C>', '<NL>', '<CR>', K_KENTER]],
-      \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '<Esc>'],
-      \		['', 'xxx', '<xxx>', '<Esc', '<C-C>', '<NL>', '<CR>', K_KENTER]],
+      \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<t_xx>', '<', '^'],
+      \		['', 'xxx', '<xxx>', '<Esc', '<t_xx', '<C-C>', '<NL>', '<CR>', K_KENTER]],
+      \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<', '^'],
+      \		['', 'xxx', '<xxx>', '<Esc', '<t_xx', '<C-C>', '<NL>', '<CR>', K_KENTER]],
       \ 'winheight': [[1, 10, 999], [-1, 0]],
       \ 'winminheight': [[0, 1], [-1]],
       \ 'winminwidth': [[0, 1, 10], [-1]],
@@ -79,7 +79,8 @@ let test_values = {
       \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
       \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
       \ 'casemap': [['', 'internal'], ['xxx']],
-      \ 'cedit': [['', '^Y', '<Esc>'], ['xxx', 'f', '<xxx>']],
+      \ 'cedit': [['', '^Y', '^@', '<Esc>', '<t_xx>'],
+      \		['xxx', 'f', '<xxx>', '<Esc', '<t_xx']],
       \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed', 'html', 'exclude:vimdisplay'], ['xxx', '\ze*', 'exclude:\\%(']],
       \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
       \ 'comments': [['', 'b:#'], ['xxx']],
@@ -157,6 +158,8 @@ let test_values = {
       \ 'term': [[], []],
       \ 'termguicolors': [[], []],
       \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
+      \ 'termwinkey': [['', 'f', '^Y', '^@', '<Esc>', '<t_xx>', "\u3042", '<', '^'],
+      \		['<xxx>', '<Esc', '<t_xx']],
       \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
       \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
       \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    762,
+/**/
     761,
 /**/
     760,