mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	Merge pull request #19921 from zeertzjq/vim-8.2.3937
vim-patch:8.2.{3937,3944}: Insert mode completion refactoring
			
			
This commit is contained in:
		| @@ -5654,7 +5654,7 @@ static char_u *do_insert_char_pre(int c) | ||||
|   return res; | ||||
| } | ||||
|  | ||||
| bool can_cindent_get(void) | ||||
| bool get_can_cindent(void) | ||||
| { | ||||
|   return can_cindent; | ||||
| } | ||||
|   | ||||
							
								
								
									
										1855
									
								
								src/nvim/insexpand.c
									
									
									
									
									
								
							
							
						
						
									
										1855
									
								
								src/nvim/insexpand.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -44,11 +44,11 @@ func Test_ins_complete() | ||||
|   exe "normal o\<C-X>\<C-P>\<C-P>\<C-X>\<C-X>\<C-N>\<C-X>\<C-N>\<C-N>" | ||||
|   call assert_equal('run1 run2', getline('.')) | ||||
|  | ||||
|   set cpt=.,w,i | ||||
|   set cpt=.,\ ,w,i | ||||
|   " i-add-expands and switches to local | ||||
|   exe "normal OM\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-X>\<C-X>\<C-P>" | ||||
|   call assert_equal("Makefile\tto\trun3", getline('.')) | ||||
|   " add-expands lines (it would end in an empty line if it didn't ignored | ||||
|   " add-expands lines (it would end in an empty line if it didn't ignore | ||||
|   " itself) | ||||
|   exe "normal o\<C-X>\<C-L>\<C-X>\<C-L>\<C-P>\<C-P>" | ||||
|   call assert_equal("Makefile\tto\trun3", getline('.')) | ||||
| @@ -721,6 +721,17 @@ func Test_complete_across_line() | ||||
|   close! | ||||
| endfunc | ||||
|  | ||||
| " Test for completing words with a '.' at the end of a word. | ||||
| func Test_complete_joinspaces() | ||||
|   new | ||||
|   call setline(1, ['one two.', 'three. four']) | ||||
|   set joinspaces | ||||
|   exe "normal Goon\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>" | ||||
|   call assert_equal("one two.  three. four", getline(3)) | ||||
|   set joinspaces& | ||||
|   bw! | ||||
| endfunc | ||||
|  | ||||
| " Test for using CTRL-L to add one character when completing matching | ||||
| func Test_complete_add_onechar() | ||||
|   new | ||||
| @@ -741,6 +752,39 @@ func Test_complete_add_onechar() | ||||
|   close! | ||||
| endfunc | ||||
|  | ||||
| " Test for using CTRL-X CTRL-L to complete whole lines lines | ||||
| func Test_complete_wholeline() | ||||
|   new | ||||
|   " complete one-line | ||||
|   call setline(1, ['a1', 'a2']) | ||||
|   exe "normal ggoa\<C-X>\<C-L>" | ||||
|   call assert_equal(['a1', 'a1', 'a2'], getline(1, '$')) | ||||
|   " go to the next match (wrapping around the buffer) | ||||
|   exe "normal 2GCa\<C-X>\<C-L>\<C-N>" | ||||
|   call assert_equal(['a1', 'a', 'a2'], getline(1, '$')) | ||||
|   " go to the next match | ||||
|   exe "normal 2GCa\<C-X>\<C-L>\<C-N>\<C-N>" | ||||
|   call assert_equal(['a1', 'a2', 'a2'], getline(1, '$')) | ||||
|   exe "normal 2GCa\<C-X>\<C-L>\<C-N>\<C-N>\<C-N>" | ||||
|   call assert_equal(['a1', 'a1', 'a2'], getline(1, '$')) | ||||
|   " repeat the test using CTRL-L | ||||
|   " go to the next match (wrapping around the buffer) | ||||
|   exe "normal 2GCa\<C-X>\<C-L>\<C-L>" | ||||
|   call assert_equal(['a1', 'a2', 'a2'], getline(1, '$')) | ||||
|   " go to the next match | ||||
|   exe "normal 2GCa\<C-X>\<C-L>\<C-L>\<C-L>" | ||||
|   call assert_equal(['a1', 'a', 'a2'], getline(1, '$')) | ||||
|   exe "normal 2GCa\<C-X>\<C-L>\<C-L>\<C-L>\<C-L>" | ||||
|   call assert_equal(['a1', 'a1', 'a2'], getline(1, '$')) | ||||
|   %d | ||||
|   " use CTRL-X CTRL-L to add one more line | ||||
|   call setline(1, ['a1', 'b1']) | ||||
|   setlocal complete=. | ||||
|   exe "normal ggOa\<C-X>\<C-L>\<C-X>\<C-L>\<C-X>\<C-L>" | ||||
|   call assert_equal(['a1', 'b1', '', 'a1', 'b1'], getline(1, '$')) | ||||
|   bw! | ||||
| endfunc | ||||
|  | ||||
| " Test insert completion with 'cindent' (adjust the indent) | ||||
| func Test_complete_with_cindent() | ||||
|   new | ||||
| @@ -829,6 +873,25 @@ func Test_complete_stop() | ||||
|   close! | ||||
| endfunc | ||||
|  | ||||
| " Test for typing CTRL-R in insert completion mode to insert a register | ||||
| " content. | ||||
| func Test_complete_reginsert() | ||||
|   new | ||||
|   call setline(1, ['a1', 'a12', 'a123', 'a1234']) | ||||
|  | ||||
|   " if a valid CTRL-X mode key is returned from <C-R>=, then it should be | ||||
|   " processed. Otherwise, CTRL-X mode should be stopped and the key should be | ||||
|   " inserted. | ||||
|   exe "normal Goa\<C-P>\<C-R>=\"\\<C-P>\"\<CR>" | ||||
|   call assert_equal('a123', getline(5)) | ||||
|   let @r = "\<C-P>\<C-P>" | ||||
|   exe "normal GCa\<C-P>\<C-R>r" | ||||
|   call assert_equal('a12', getline(5)) | ||||
|   exe "normal GCa\<C-P>\<C-R>=\"x\"\<CR>" | ||||
|   call assert_equal('a1234x', getline(5)) | ||||
|   bw! | ||||
| endfunc | ||||
|  | ||||
| func Test_issue_7021() | ||||
|   CheckMSWindows | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 zeertzjq
					zeertzjq