Skip to content

Commit

Permalink
Fix bug where a lone '.' was scoped as a decimal point; closes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
Phidica committed Oct 23, 2017
1 parent b06b900 commit 3b6e78e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions fish.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ repository:
patterns:
- comment: Treat a sequence of integers (with possible decimal separator) as a standalone constant. Do this separate to string-unquoted-pattens so we can ensure it is a string solely of numbers
name: meta.string.unquoted.fish constant.numeric.fish
match: (?:[0-9\.]+)(?=[\s;&)|<>'"])
match: (?:[0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(?=[\s;&)|<>'"])

- name: meta.string.unquoted.fish
begin: (?!['"])
Expand Down Expand Up @@ -902,7 +902,7 @@ repository:
- comment: Manually recreate the #string rule with extra logic in unquoted strings, and don't repeat the meta.string.unquoted scope
- include: '#string-quoted'
- name: constant.numeric.fish
match: (?:[0-9\.]+)(?=[\s;&)|<>'"]|\}|\,)
match: (?:[0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(?=[\s;&)|<>'"]|\}|\,)
- begin: (?![\s'"])
end: (?=[\s;&)|<>'"]|\}|\,)
comment: Begin/end string as before with the addition of breaking at a '}' or ','
Expand Down
4 changes: 2 additions & 2 deletions fish.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,7 @@
<key>comment</key>
<string>Treat a sequence of integers (with possible decimal separator) as a standalone constant. Do this separate to string-unquoted-pattens so we can ensure it is a string solely of numbers</string>
<key>match</key>
<string>(?:[0-9\.]+)(?=[\s;&amp;)|&lt;&gt;'"])</string>
<string>(?:[0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(?=[\s;&amp;)|&lt;&gt;'"])</string>
<key>name</key>
<string>meta.string.unquoted.fish constant.numeric.fish</string>
</dict>
Expand Down Expand Up @@ -2218,7 +2218,7 @@
</dict>
<dict>
<key>match</key>
<string>(?:[0-9\.]+)(?=[\s;&amp;)|&lt;&gt;'"]|\}|\,)</string>
<string>(?:[0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(?=[\s;&amp;)|&lt;&gt;'"]|\}|\,)</string>
<key>name</key>
<string>constant.numeric.fish</string>
</dict>
Expand Down
16 changes: 15 additions & 1 deletion syntax_test_fish.fish
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ echo str1 2 3str -b"str" --num=2
#! ^^^^^^ meta.string.unquoted
#! ^ constant.numeric

echo 1 1.2 .3 4. .
#! ^ constant.numeric
#! ^^^ constant.numeric
#! ^^ constant.numeric
#! ^^ constant.numeric
#! ^ - constant.numeric

cmd -a --arg -- -- -h # comment
#! ^^ variable.parameter
#! ^^^^^ variable.parameter
Expand Down Expand Up @@ -620,11 +627,12 @@ echo $var $var[$var[1 $var[1]] $var[1..2]] "str"
#! ^^^^ meta.brackets.index-expansion meta.brackets.index-expansion variable.other
#! ^^^^^ string.quoted
echo $$var[ 1 ][ 1 ]
echo $$var[ 1 ][ 1 ] $var[1.2]
#! ^^^^^^^^^^^^^^^ meta.variable-expansion
#! ^^^^ variable.other
#! ^^^^^ meta.brackets.index-expansion
#! ^^^^^ meta.brackets.index-expansion
#! ^^^ - constant.numeric
echo $var[(echo 1)] $var["2"] "str"
#! ^^^^ variable.other
Expand Down Expand Up @@ -678,6 +686,12 @@ echo $var{,'brace',"expansion",he{e,$e}re\,}"str"
#! ^ punctuation.section.braces.end
#! ^^^^^ string.quoted

echo 1{1.2,2a}3
#! ^ - constant.numeric
#! ^^^ constant.numeric
#! ^ - constant.numeric
#! ^ - constant.numeric

echo %"fish" one%two %%percent
#! ^^^^^^^ meta.process-expansion
#! ^ punctuation.definition.process
Expand Down

0 comments on commit 3b6e78e

Please sign in to comment.