fix(chroma/ssh): treat -R and -Q as flags that take an argument - #91
Merged
pschmitt merged 1 commit intoAug 31, 2026
Merged
Conversation
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 zdharma-continuum#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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
→chroma/-ssh.chkeeps a list ofsshflags whose argument must be skipped, so that the argument is not counted as the hostname:Every alternative is hyphenated except two —
QandRare written bare — so-Qand-Rnever match:What you see
skip-twois never set, so5037:localhost:5037is counted as the first non-option token and becomes the hostname. Its trailing:5037then matches the host:port check on line 106, and line 143 callszle -M:That appears while typing, on a completely valid command line, and the forward spec is coloured as a bad host.
-Lis in the list correctly, so the identical local forward highlights fine — only-Rtrips it.-Qmislabels its argument as the host in the same way, though it does not reach the message.The fix
Two hyphens:
|-p|Q|R|-S|→|-p|-Q|-R|-S|.Tests
Two added to
tests/main.zunit:ssh -R 5037:localhost:5037 devboxmust produce no message — fails on master, passes with this change.ssh devbox:22must still produce the message — passes both ways, so the feature itself is unchanged.Chromas are autoloaded functions, so
@setupnow adds the repo tofpathand autoloads the ssh chroma, the way the plugin file does at startup.Verified on zsh 5.9, macOS arm64, with the zunit revision the CI workflow pins.
Related
#33 reports
-LRDforwarding specs highlighting incorrectly. This fixes the-Rhalf of it; the request there for colouring the components of a forward spec is separate and not addressed here.