mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	vim-patch:8.2.5058: input() does not handle composing characters properly
Problem:    input() does not handle composing characters properly.
Solution:   Use mb_cptr2char_adv() instead of mb_ptr2char_adv().
            (closes vim/vim#10527)
e3a529bc87
Cherry-pick all of Test_input_func() from patch 8.2.0316.
(cherry picked from commit 84ed71f319)
			
			
This commit is contained in:
		 zeertzjq
					zeertzjq
				
			
				
					committed by
					
						![github-actions[bot]](/assets/img/avatar_default.png) github-actions[bot]
						github-actions[bot]
					
				
			
			
				
	
			
			
			![github-actions[bot]](/assets/img/avatar_default.png) github-actions[bot]
						github-actions[bot]
					
				
			
						parent
						
							2146a48587
						
					
				
				
					commit
					6768784feb
				
			| @@ -631,7 +631,7 @@ void stuffReadbuffSpec(const char *s) | |||||||
|       stuffReadbuffLen(s, 3); |       stuffReadbuffLen(s, 3); | ||||||
|       s += 3; |       s += 3; | ||||||
|     } else { |     } else { | ||||||
|       int c = mb_ptr2char_adv((const char_u **)&s); |       int c = mb_cptr2char_adv((const char_u **)&s); | ||||||
|       if (c == CAR || c == NL || c == ESC) { |       if (c == CAR || c == NL || c == ESC) { | ||||||
|         c = ' '; |         c = ' '; | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -1180,6 +1180,45 @@ func Test_col() | |||||||
|   bw! |   bw! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " Test for input() | ||||||
|  | func Test_input_func() | ||||||
|  |   " Test for prompt with multiple lines | ||||||
|  |   redir => v | ||||||
|  |   call feedkeys(":let c = input(\"A\\nB\\nC\\n? \")\<CR>B\<CR>", 'xt') | ||||||
|  |   redir END | ||||||
|  |   call assert_equal("B", c) | ||||||
|  |   call assert_equal(['A', 'B', 'C'], split(v, "\n")) | ||||||
|  |  | ||||||
|  |   " Test for default value | ||||||
|  |   call feedkeys(":let c = input('color? ', 'red')\<CR>\<CR>", 'xt') | ||||||
|  |   call assert_equal('red', c) | ||||||
|  |  | ||||||
|  |   " Test for completion at the input prompt | ||||||
|  |   func! Tcomplete(arglead, cmdline, pos) | ||||||
|  |     return "item1\nitem2\nitem3" | ||||||
|  |   endfunc | ||||||
|  |   call feedkeys(":let c = input('Q? ', '', 'custom,Tcomplete')\<CR>" | ||||||
|  |         \ .. "\<C-A>\<CR>", 'xt') | ||||||
|  |   delfunc Tcomplete | ||||||
|  |   call assert_equal('item1 item2 item3', c) | ||||||
|  |  | ||||||
|  |   " Test for using special characters as default input | ||||||
|  |   call feedkeys(":let c = input('name? ', \"x\\<BS>y\")\<CR>\<CR>", 'xt') | ||||||
|  |   call assert_equal('y', c) | ||||||
|  |  | ||||||
|  |   " Test for using text with composing characters as default input | ||||||
|  |   call feedkeys(":let c = input('name? ', \"ã̳\")\<CR>\<CR>", 'xt') | ||||||
|  |   call assert_equal('ã̳', c) | ||||||
|  |  | ||||||
|  |   " Test for using <CR> as default input | ||||||
|  |   call feedkeys(":let c = input('name? ', \"\\<CR>\")\<CR>x\<CR>", 'xt') | ||||||
|  |   call assert_equal(' x', c) | ||||||
|  |  | ||||||
|  |   call assert_fails("call input('F:', '', 'invalid')", 'E180:') | ||||||
|  |   call assert_fails("call input('F:', '', [])", 'E730:') | ||||||
|  | endfunc | ||||||
|  |  | ||||||
|  | " Test for inputlist() | ||||||
| func Test_inputlist() | func Test_inputlist() | ||||||
|   call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx') |   call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx') | ||||||
|   call assert_equal(1, c) |   call assert_equal(1, c) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user