diff --git a/tests/main.zunit b/tests/main.zunit index 110f34c..42b91f0 100644 --- a/tests/main.zunit +++ b/tests/main.zunit @@ -3,6 +3,9 @@ load "../fast-highlight" setopt interactive_comments -fast-highlight-fill-option-variables + # Chromas are autoloaded functions; the plugin file does this at startup. + fpath+=( "$PWD" ) + autoload -Uz -- '→chroma/-ssh.ch' } @test 'ls /usr/bin' { @@ -121,4 +124,25 @@ reply=() assert "$reply[9]" same_as "" } +@test 'ssh -R 5037:localhost:5037 devbox' { + reply=() + PREBUFFER="" + BUFFER="ssh -R 5037:localhost:5037 devbox" + evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 + + # -R takes an argument, so the forward spec is not the hostname and its + # trailing :5037 is not a port passed to a hostspec. + assert "${FAST_HIGHLIGHT[chroma-ssh-message]}" same_as "" +} + +@test 'ssh devbox:22' { + reply=() + PREBUFFER="" + BUFFER="ssh devbox:22" + evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 + + # A port really passed in the hostspec is still reported. + assert "${FAST_HIGHLIGHT[chroma-ssh-message]}" same_as "Format of hostname incorrect, use -p to pass port number" +} + # vim:ft=zsh:sw=4:sts=4:et diff --git "a/\342\206\222chroma/-ssh.ch" "b/\342\206\222chroma/-ssh.ch" index 1d5e257..cd48e84 100644 --- "a/\342\206\222chroma/-ssh.ch" +++ "b/\342\206\222chroma/-ssh.ch" @@ -51,7 +51,7 @@ local -a match mbegin mend completions_users completions_host # Detected option, add style for it. [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ __style=${FAST_THEME_NAME}single-hyphen-option - if [[ "$__wrd" = (-b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-O|-o|-p|Q|R|-S|-W|-w) ]]; then + if [[ "$__wrd" = (-b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-O|-o|-p|-Q|-R|-S|-W|-w) ]]; then FAST_HIGHLIGHT[chroma-ssh-skip-two]=1 fi else