xC: make libedit autocomplete less miserable
Omitting even this hack was a huge hit to overall usability.
This commit is contained in:
		
							parent
							
								
									9e297244a4
								
							
						
					
					
						commit
						df4ca74580
					
				
							
								
								
									
										26
									
								
								xC.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								xC.c
									
									
									
									
									
								
							| @ -13698,19 +13698,33 @@ on_editline_complete (EditLine *editline, int key) | |||||||
| 
 | 
 | ||||||
| 	// Insert the best match instead
 | 	// Insert the best match instead
 | ||||||
| 	el_insertstr (editline, completions[0]); | 	el_insertstr (editline, completions[0]); | ||||||
|  | 
 | ||||||
|  | 	// I'm not sure if Readline's menu-complete can at all be implemented
 | ||||||
|  | 	// with Editline--we have no way of detecting what the last executed handler
 | ||||||
|  | 	// was.  Employ the formatter's wrapping feature to spew all options.
 | ||||||
| 	bool only_match = !completions[1]; | 	bool only_match = !completions[1]; | ||||||
|  | 	if (!only_match) | ||||||
|  | 	{ | ||||||
|  | 		CALL (ctx->input, hide); | ||||||
|  | 		redraw_screen (ctx); | ||||||
|  | 
 | ||||||
|  | 		struct formatter f = formatter_make (ctx, NULL); | ||||||
|  | 		for (char **p = completions; *++p; ) | ||||||
|  | 			formatter_add (&f, " #l", *p); | ||||||
|  | 		formatter_add (&f, "\n"); | ||||||
|  | 		formatter_flush (&f, stdout, 0); | ||||||
|  | 		formatter_free (&f); | ||||||
|  | 
 | ||||||
|  | 		CALL (ctx->input, show); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	for (char **p = completions; *p; p++) | 	for (char **p = completions; *p; p++) | ||||||
| 		free (*p); | 		free (*p); | ||||||
| 	free (completions); | 	free (completions); | ||||||
| 
 |  | ||||||
| 	// I'm not sure if Readline's menu-complete can at all be implemented
 |  | ||||||
| 	// with Editline.  Spamming the terminal with possible completions
 |  | ||||||
| 	// probably isn't what the user wants and we have no way of detecting
 |  | ||||||
| 	// what the last executed handler was.
 |  | ||||||
| 	if (!only_match) | 	if (!only_match) | ||||||
| 		return CC_REFRESH_BEEP; | 		return CC_REFRESH_BEEP; | ||||||
| 
 | 
 | ||||||
| 	// But if there actually is just one match, finish the word
 | 	// If there actually is just one match, finish the word
 | ||||||
| 	el_insertstr (editline, " "); | 	el_insertstr (editline, " "); | ||||||
| 	return CC_REFRESH; | 	return CC_REFRESH; | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user