Move sub-command options reply out of the for-loop
It was just before the `break` statement anyways
This commit is contained in:
		
							parent
							
								
									e2b2c2fb2e
								
							
						
					
					
						commit
						f5d2a6bcc3
					
				| @ -24,10 +24,8 @@ _hledger_completion_function() { | ||||
|     compopt -o filenames | ||||
| 
 | ||||
|     local subcommand | ||||
|     local subcommandOptions | ||||
|     local i | ||||
| 
 | ||||
|     for (( i=1; i<${#words[@]}; i++ )); do | ||||
|     for ((i=1; i<${#words[@]}; i++)); do | ||||
|         subcommand=${words[i]} | ||||
|         if ! grep -Fxqe "$subcommand" <<< "$_hledger_complist_commands"; then | ||||
|             subcommand= | ||||
| @ -48,17 +46,6 @@ _hledger_completion_function() { | ||||
|                 return 0 | ||||
|             fi | ||||
|         fi | ||||
|         if [[ $cur == -* ]]; then | ||||
|             # Replace dashes with underscores and use indirect expansion | ||||
|             subcommandOptions=_hledger_complist_options_${subcommand//-/_} | ||||
|             _hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")" | ||||
| 
 | ||||
|             # Suspend space on completion of long options requiring an argument | ||||
|             [[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace | ||||
|             compopt +o filenames | ||||
| 
 | ||||
|             return 0 | ||||
|         fi | ||||
|         break | ||||
|     done | ||||
| 
 | ||||
| @ -79,6 +66,19 @@ _hledger_completion_function() { | ||||
|         return 0 | ||||
|     fi | ||||
| 
 | ||||
|     if [[ $cur == -* ]]; then | ||||
|         local subcommandOptions | ||||
|         # Replace dashes with underscores and use indirect expansion | ||||
|         subcommandOptions=_hledger_complist_options_${subcommand//-/_} | ||||
|         _hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")" | ||||
| 
 | ||||
|         # Suspend space on completion of long options requiring an argument | ||||
|         [[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace | ||||
|         compopt +o filenames | ||||
| 
 | ||||
|         return 0 | ||||
|     fi | ||||
| 
 | ||||
|     # Query completion | ||||
|     _hledger_compreply_query && return | ||||
| 
 | ||||
|  | ||||
| @ -24,10 +24,8 @@ _hledger_completion_function() { | ||||
|     compopt -o filenames | ||||
| 
 | ||||
|     local subcommand | ||||
|     local subcommandOptions | ||||
|     local i | ||||
| 
 | ||||
|     for (( i=1; i<${#words[@]}; i++ )); do | ||||
|     for ((i=1; i<${#words[@]}; i++)); do | ||||
|         subcommand=${words[i]} | ||||
|         if ! grep -Fxqe "$subcommand" <<< "$_hledger_complist_commands"; then | ||||
|             subcommand= | ||||
| @ -48,17 +46,6 @@ _hledger_completion_function() { | ||||
|                 return 0 | ||||
|             fi | ||||
|         fi | ||||
|         if [[ $cur == -* ]]; then | ||||
|             # Replace dashes with underscores and use indirect expansion | ||||
|             subcommandOptions=_hledger_complist_options_${subcommand//-/_} | ||||
|             _hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")" | ||||
| 
 | ||||
|             # Suspend space on completion of long options requiring an argument | ||||
|             [[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace | ||||
|             compopt +o filenames | ||||
| 
 | ||||
|             return 0 | ||||
|         fi | ||||
|         break | ||||
|     done | ||||
| 
 | ||||
| @ -79,6 +66,19 @@ _hledger_completion_function() { | ||||
|         return 0 | ||||
|     fi | ||||
| 
 | ||||
|     if [[ $cur == -* ]]; then | ||||
|         local subcommandOptions | ||||
|         # Replace dashes with underscores and use indirect expansion | ||||
|         subcommandOptions=_hledger_complist_options_${subcommand//-/_} | ||||
|         _hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")" | ||||
| 
 | ||||
|         # Suspend space on completion of long options requiring an argument | ||||
|         [[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace | ||||
|         compopt +o filenames | ||||
| 
 | ||||
|         return 0 | ||||
|     fi | ||||
| 
 | ||||
|     # Query completion | ||||
|     _hledger_compreply_query && return | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user