Add build#dir() popup_menu() fallback
When `popup_menu()` is not available, i.e. neovim or old version of vim, fallback to using `inputlist()` instead.
This commit is contained in:
		
							parent
							
								
									7491736987
								
							
						
					
					
						commit
						eabec4e9b6
					
				| @ -10,12 +10,25 @@ function! build#dir(...) abort | |||||||
|       let l:dir = s:dirs[0] |       let l:dir = s:dirs[0] | ||||||
|       unlet s:dirs |       unlet s:dirs | ||||||
|     else |     else | ||||||
|       " Multiple build directories found, create popup menu to select one. |       " Multiple build directories found, select one. | ||||||
|       " Set the callback to this function on completion, handled below. |       if exists('*popup_menu') | ||||||
|       call popup_menu(s:dirs, #{ |         " Create popup menu to select the build directory. Callback to this | ||||||
|       \   filter: 'popup_filter_menu', |         " function on completion, handled in the else branch below. | ||||||
|       \   callback: 'build#dir', |         call popup_menu(s:dirs, #{ | ||||||
|       \ }) |         \   filter: 'popup_filter_menu', | ||||||
|  |         \   callback: 'build#dir', | ||||||
|  |         \ }) | ||||||
|  |       else | ||||||
|  |         " Fallback to inputlist when popup_menu is not available. | ||||||
|  |         let l:choices = [] | ||||||
|  |         let l:index = 1 | ||||||
|  |         for l:dir in s:dirs | ||||||
|  |           call add(l:choices, string(l:index).': '.l:dir) | ||||||
|  |           let l:index += 1 | ||||||
|  |         endfor | ||||||
|  |         let l:index = inputlist(l:choices) | ||||||
|  |         let l:dir = s:dirs[l:index - 1] | ||||||
|  |       endif | ||||||
|     endif |     endif | ||||||
|   else |   else | ||||||
|     if a:0 == 1 |     if a:0 == 1 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user