mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	vim-patch:9.1.1269: completion: compl_shown_match is updated when starting keyword completion
Problem:  compl_shown_match is updated when starting keyword completion
          and does not include fuzzy matching.
Solution: Do not update compl_shown_match when starting keyword
          completion, since it is the one already selected by the
          keyword completion direction. (glepnir)
closes: vim/vim#17033
e4e4d1c381
Co-authored-by: glepnir <glephunter@gmail.com>
(cherry picked from commit 8cf413e450)
			
			
This commit is contained in:
		
				
					committed by
					
						
						github-actions[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							cbf4906c11
						
					
				
				
					commit
					02bf23b4bf
				
			@@ -1242,6 +1242,12 @@ static int ins_compl_build_pum(void)
 | 
			
		||||
  // match after it, don't highlight anything.
 | 
			
		||||
  bool shown_match_ok = match_at_original_text(compl_shown_match);
 | 
			
		||||
 | 
			
		||||
  bool update_shown_match = fuzzy_filter;
 | 
			
		||||
  if (fuzzy_filter && ctrl_x_mode_normal()
 | 
			
		||||
      && compl_leader.data == NULL && compl_shown_match->cp_score > 0) {
 | 
			
		||||
    update_shown_match = false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (strequal(compl_leader.data, compl_orig_text.data) && !shown_match_ok) {
 | 
			
		||||
    compl_shown_match = compl_no_select ? compl_first_match : compl_first_match->cp_next;
 | 
			
		||||
  }
 | 
			
		||||
@@ -1290,7 +1296,7 @@ static int ins_compl_build_pum(void)
 | 
			
		||||
        }
 | 
			
		||||
        // Update the maximum fuzzy score and the shown match
 | 
			
		||||
        // if the current item's score is higher
 | 
			
		||||
        if (fuzzy_sort && comp->cp_score > max_fuzzy_score) {
 | 
			
		||||
        if (fuzzy_sort && comp->cp_score > max_fuzzy_score && update_shown_match) {
 | 
			
		||||
          did_find_shown_match = true;
 | 
			
		||||
          max_fuzzy_score = comp->cp_score;
 | 
			
		||||
          if (!compl_no_select) {
 | 
			
		||||
 
 | 
			
		||||
@@ -2881,6 +2881,12 @@ func Test_complete_fuzzy_match()
 | 
			
		||||
  call feedkeys("i\<C-R>=CompAnother()\<CR>\<C-P>\<C-P>", 'tx')
 | 
			
		||||
  call assert_equal("for", g:abbr)
 | 
			
		||||
 | 
			
		||||
  set cot=menu,fuzzy
 | 
			
		||||
  call feedkeys("Sblue\<CR>bar\<CR>b\<C-X>\<C-P>\<C-Y>\<ESC>", 'tx')
 | 
			
		||||
  call assert_equal('bar', getline('.'))
 | 
			
		||||
  call feedkeys("Sb\<C-X>\<C-N>\<C-Y>\<ESC>", 'tx')
 | 
			
		||||
  call assert_equal('blue', getline('.'))
 | 
			
		||||
 | 
			
		||||
  " clean up
 | 
			
		||||
  set omnifunc=
 | 
			
		||||
  bw!
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user