'main': Don't highlight unknown precommand flags as errors.
We cannot now for sure whether the flag is misspelled or simply unknown to us, so err on the side of caution. This fixes an unreleased regression. Fixes #658. Issue #641 was originally filed about this problem, but is left open to track further enhancements.
This commit is contained in:
		
							parent
							
								
									3a6f7e7bfe
								
							
						
					
					
						commit
						5012d771f3
					
				|  | @ -662,12 +662,9 @@ _zsh_highlight_main_highlighter_highlight_list() | |||
|           next_word+=':start:' | ||||
|           next_word+=':sudo_opt:' | ||||
|         elif [[ $arg == '-'* ]]; then | ||||
|           # Unknown flag | ||||
|           # Unknown flag.  We don't know whether it takes an argument or not, | ||||
|           # so we don't modify $next_word. | ||||
|           this_word=':sudo_opt:' | ||||
|           next_word+=':start:' | ||||
|           next_word+=':sudo_opt:' | ||||
|           _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token | ||||
|           continue | ||||
|         else | ||||
|           # Not an option flag; nothing to do.  (If the command line is | ||||
|           # syntactically valid, ${this_word//:sudo_opt:/} should be | ||||
|  |  | |||
|  | @ -38,6 +38,6 @@ expected_region_highlight=( | |||
|   '10 11 command' # ls | ||||
|   '12 12 commandseparator' # ; | ||||
|   '14 17 precommand' # sudo | ||||
|   '19 20 unknown-token' # -x | ||||
|   '22 23 command' # ls | ||||
|   '19 20 single-hyphen-option' # -x | ||||
|   '22 23 default' # ls | ||||
| ) | ||||
|  |  | |||
|  | @ -32,6 +32,6 @@ BUFFER='sudo --askpass ls' | |||
| 
 | ||||
| expected_region_highlight=( | ||||
|   '1 4 precommand' # sudo | ||||
|   '6 14 double-hyphen-option "issues #641 and #658"' # --askpass | ||||
|   '16 17 default "issues #641 and #658"' # ls (we don't know whether --askpass takes an argument) | ||||
|   '6 14 double-hyphen-option' # --askpass | ||||
|   '16 17 default' # ls (we don't know whether --askpass takes an argument) | ||||
| ) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue