Skip to content

Commit 3a4d7ff

Browse files
committed
Fix up float highlighting in Vim.
This fixes a regression introduced in #10793. Having a colorscheme which highlights Float the same as Number (I believe most do), I hadn't noticed that having the special case of "5." floats (which was one of the added features in #10793) last made it take precedence, and so it was left to @thestinger to notice it. The regression meant that in `5.0`, the `5.` was a `rustFloat` (linked by default to `Float`) and the `0` was a `rustDecNumber` (linked by default to `Number`), and for `5.0f32` the `5.` was a `rustFloat` and the `0f32` was a second `rustFloat` (and thus appeared correctly, though for the wrong reason).
1 parent 29ca435 commit 3a4d7ff

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/etc/vim/syntax/rust.vim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: 2013 Dec 04
6+
" Last Change: 2013 Dec 10
77

88
if version < 600
99
syntax clear
@@ -160,14 +160,15 @@ syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(8\|16\|32\|64
160160
syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\="
161161
syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\="
162162

163-
" To mark it as a float, it must have at least one of the three things integral values don't have:
163+
" Special case for numbers of the form "1." which are float literals, unless followed by
164+
" an identifier, which makes them integer literals with a method call or field access.
165+
" (This must go first so the others take precedence.)
166+
syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\@!"
167+
" To mark a number as a normal float, it must have at least one of the three things integral values don't have:
164168
" a decimal point and more numbers; an exponent; and a type suffix.
165169
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\="
166170
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\(f32\|f64\)\="
167171
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)"
168-
" Special case for numbers of the form "1." which are float literals, unless followed by
169-
" an identifier, which makes them integer literals with a method call or field access.
170-
syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\@!"
171172

172173
" For the benefit of delimitMate
173174
syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt0\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime

0 commit comments

Comments
 (0)