[gtksourceview/gtksourceview-4-2] ruby.lang: fix highlighting numbers in ranges



commit 11c4e9df76e603867cb3d236c2db6498b815fe3f
Author: Vlasta Vesely <vlastavesely protonmail ch>
Date:   Sat Jan 4 14:02:18 2020 +0100

    ruby.lang: fix highlighting numbers in ranges

 data/language-specs/ruby.lang     | 12 ++++++------
 tests/syntax-highlighting/file.rb |  8 ++++++++
 2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/data/language-specs/ruby.lang b/data/language-specs/ruby.lang
index ff2625b2..c9a5b95c 100644
--- a/data/language-specs/ruby.lang
+++ b/data/language-specs/ruby.lang
@@ -386,27 +386,27 @@
     </define-regex>
 
     <context id="float" style-ref="floating-point">
-      <match>(?&lt;![\w\.])\%{float}(?![\w\.])</match>
+      <match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))\%{float}((?![\w\.])|(?=\.\.))(?!\.\.\.\.)</match>
     </context>
 
     <context id="decimal" style-ref="decimal">
-      <match>(?&lt;![\w\.])([1-9](_?[0-9])*|0)(?![\w\.])</match>
+      
<match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))([1-9](_?[0-9])*|0)((?![\w\.])|(?=\.\.))(?!\.\.\.\.)</match>
     </context>
 
     <context id="hex" style-ref="base-n-integer">
-      <match>(?&lt;![\w\.])0[xX][0-9A-Fa-f](_?[0-9A-Fa-f])*(?![\w\.])</match>
+      
<match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))0[xX][0-9A-Fa-f](_?[0-9A-Fa-f])*((?![\w\.])|(?=\.\.))(?!\.\.\.\.)</match>
     </context>
 
     <context id="octal" style-ref="base-n-integer">
-      <match>(?&lt;![\w\.])0[0-7](_?[0-7])*(?![\w\.])</match>
+      
<match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))0[0-7](_?[0-7])*((?![\w\.])|(?=\.\.))(?!\.\.\.\.)</match>
     </context>
 
     <context id="binary" style-ref="base-n-integer">
-      <match>(?&lt;![\w\.])0[bB][01](_?[01])*(?![\w\.])</match>
+      
<match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))0[bB][01](_?[01])*((?![\w\.])|(?=\.\.))(?!\.\.\.\.)</match>
     </context>
 
     <context id="numeric-literal" style-ref="numeric-literal">
-      <match>(?&lt;![\w\.])\?((\\[MC]-){1,2}|\\?)\S</match>
+      <match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))\?((\\[MC]-){1,2}|\\?)\S</match>
     </context>
 
     <!-- in double quotes and backticks -->
diff --git a/tests/syntax-highlighting/file.rb b/tests/syntax-highlighting/file.rb
index 04f71244..2d243f15 100644
--- a/tests/syntax-highlighting/file.rb
+++ b/tests/syntax-highlighting/file.rb
@@ -1,3 +1,11 @@
 #!/usr/bin/env ruby
 #
 puts "\141" # Shows 'a'
+
+str = 'lorem'
+puts str[1..3] # 'ore'
+
+# Ranges
+11..11, 0x11..0x11, 01..07, ?a..?f, 1.1..2.2 # range incl. the last value
+11...11, 0x11...0x11, 01...07, ?a...?f, 1.1...2.2 # range excl. the last value
+11....111, 0x11......0x11, 1.1.....1.2 # 4 (and more) dots are not a valid range


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]