From 3b6e78e598e62be3b425156970aa927f116d7cb2 Mon Sep 17 00:00:00 2001 From: Phidica Veia Date: Mon, 23 Oct 2017 22:36:21 +1030 Subject: [PATCH] Fix bug where a lone '.' was scoped as a decimal point; closes #10 --- fish.YAML-tmLanguage | 4 ++-- fish.tmLanguage | 4 ++-- syntax_test_fish.fish | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/fish.YAML-tmLanguage b/fish.YAML-tmLanguage index 74d351a..77fa02b 100644 --- a/fish.YAML-tmLanguage +++ b/fish.YAML-tmLanguage @@ -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: (?!['"]) @@ -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 ',' diff --git a/fish.tmLanguage b/fish.tmLanguage index 903617a..edb96ad 100644 --- a/fish.tmLanguage +++ b/fish.tmLanguage @@ -2111,7 +2111,7 @@ 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 match - (?:[0-9\.]+)(?=[\s;&)|<>'"]) + (?:[0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(?=[\s;&)|<>'"]) name meta.string.unquoted.fish constant.numeric.fish @@ -2218,7 +2218,7 @@ match - (?:[0-9\.]+)(?=[\s;&)|<>'"]|\}|\,) + (?:[0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(?=[\s;&)|<>'"]|\}|\,) name constant.numeric.fish diff --git a/syntax_test_fish.fish b/syntax_test_fish.fish index f0462cd..23374d2 100644 --- a/syntax_test_fish.fish +++ b/syntax_test_fish.fish @@ -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 @@ -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 @@ -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