mirror of
https://github.com/zdharma-continuum/fast-syntax-highlighting.git
synced 2026-09-10 07:16:18 -04:00
fix(chroma/ssh): treat -R and -Q as flags that take an argument (#91)
Some checks failed
zunit / zunit (push) Has been cancelled
Some checks failed
zunit / zunit (push) Has been cancelled
The ssh chroma keeps a list of flags whose argument must be skipped, so the
argument is not mistaken for the hostname. Every entry is hyphenated except
two: `Q` and `R` are written bare, so `-Q` and `-R` never match.
For `-R` the consequence is visible. Typing
ssh -R 5037:localhost:5037 devbox
leaves `5037:localhost:5037` counted as the first non-option token, so it
becomes the hostname. Its trailing `:5037` then matches the host:port check and
the chroma calls `zle -M` with
Format of hostname incorrect, use -p to pass port number
while you type, on a command line that is perfectly valid. `-L` is in the list
correctly, so the identical local-forward spec highlights fine and only the
remote forward is affected. `-Q` mislabels its argument as the host in the same
way, without reaching the message.
Adds two tests: `-R` must stay silent, and a hostspec that really does carry a
port must still be reported.
Related to #33, which reports `-LRD` forwarding specs highlighting wrongly;
this fixes the `-R` half.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3d574ccf48
commit
4672ad5dd9
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue