Simplify sub-command loop logic
If the cursor is on the sub-command, just offer sub-command completions and be done with it. It was way over complicated.
This commit is contained in:
		
							parent
							
								
									f5d2a6bcc3
								
							
						
					
					
						commit
						046421e712
					
				| @ -36,15 +36,9 @@ _hledger_completion_function() { | |||||||
|         # $subcommand == bal --> balance, balancesheet, balancesheetequity, etc. |         # $subcommand == bal --> balance, balancesheet, balancesheetequity, etc. | ||||||
|         # Do not ignore them! |         # Do not ignore them! | ||||||
|         if ((i == cword)); then |         if ((i == cword)); then | ||||||
|             local subcommandMatches |             compopt +o filenames | ||||||
|             subcommandMatches=$(grep -c "^$subcommand" <<< "$_hledger_complist_commands") |             _hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")" | ||||||
|             if ((subcommandMatches > 1)); then |             return 0 | ||||||
|                 subcommand= |  | ||||||
|                 break |  | ||||||
|             else |  | ||||||
|                 _hledger_compreply "$subcommand" |  | ||||||
|                 return 0 |  | ||||||
|             fi |  | ||||||
|         fi |         fi | ||||||
|         break |         break | ||||||
|     done |     done | ||||||
|  | |||||||
| @ -36,15 +36,9 @@ _hledger_completion_function() { | |||||||
|         # $subcommand == bal --> balance, balancesheet, balancesheetequity, etc. |         # $subcommand == bal --> balance, balancesheet, balancesheetequity, etc. | ||||||
|         # Do not ignore them! |         # Do not ignore them! | ||||||
|         if ((i == cword)); then |         if ((i == cword)); then | ||||||
|             local subcommandMatches |             compopt +o filenames | ||||||
|             subcommandMatches=$(grep -c "^$subcommand" <<< "$_hledger_complist_commands") |             _hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")" | ||||||
|             if ((subcommandMatches > 1)); then |             return 0 | ||||||
|                 subcommand= |  | ||||||
|                 break |  | ||||||
|             else |  | ||||||
|                 _hledger_compreply "$subcommand" |  | ||||||
|                 return 0 |  | ||||||
|             fi |  | ||||||
|         fi |         fi | ||||||
|         break |         break | ||||||
|     done |     done | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user