mirror of
https://github.com/alecthomas/chroma.git
synced 2025-02-05 13:05:18 +02:00
fish: Fix incorrect tokenisation of command arguments containing dash
Command line arguments containing dash/hyphen were incorrectly tokenised as command line options.
This commit is contained in:
parent
841c391b98
commit
9df8bd4f92
@ -74,7 +74,7 @@ func fishRules() Rules {
|
||||
{`&&|\|\||&|\||\^|<|>`, Operator, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`\b\d+\b`, LiteralNumber, nil},
|
||||
{`--?[^\d][\w-]*`, NameAttribute, nil},
|
||||
{`(?<=\s+)--?[^\d][\w-]*`, NameAttribute, nil},
|
||||
{".+?", Text, nil},
|
||||
},
|
||||
"string": {
|
||||
|
4
lexers/testdata/fish.actual
vendored
4
lexers/testdata/fish.actual
vendored
@ -24,6 +24,8 @@ set data (cat data | string split0)
|
||||
|
||||
grep fish myanimallist1 | wc -l
|
||||
|
||||
command some-arg-with-dash
|
||||
|
||||
echo input.{c,h,txt}
|
||||
|
||||
echo {$dogs}dog
|
||||
@ -241,4 +243,4 @@ function fish_config --description "Launch fish's web based configuration"
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
7
lexers/testdata/fish.expected
vendored
7
lexers/testdata/fish.expected
vendored
@ -94,6 +94,8 @@
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameAttribute","value":"-l"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"NameBuiltin","value":"command "},
|
||||
{"type":"Text","value":"some-arg-with-dash\n\n"},
|
||||
{"type":"Keyword","value":"echo"},
|
||||
{"type":"Text","value":" input."},
|
||||
{"type":"Operator","value":"{"},
|
||||
@ -865,7 +867,7 @@
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"("},
|
||||
{"type":"NameBuiltin","value":"status fish"},
|
||||
{"type":"NameAttribute","value":"-path"},
|
||||
{"type":"Text","value":"-path"},
|
||||
{"type":"Operator","value":")"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"set"},
|
||||
@ -1261,5 +1263,6 @@
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralNumber","value":"0"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"end"}
|
||||
{"type":"Keyword","value":"end"},
|
||||
{"type":"Text","value":"\n"}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user