Christian Brabandt wrote:
> Hi Dominique!
>
> On Do, 17 Nov 2016, Dominique Pellé wrote:
>
>> Hi
>>
>> I notice an incorrect syntax highlighting of literal float values with
>> cpp syntax. Bug happens with vim-8.0.86 and older, but does not
>> happen with vim-7.4.1689 that comes with ubuntu-16.04. So
>> somewhere in between, a regression was introduced.
>>
>> Steps to reproduce:
>>
>> $ cat >foo.cpp <<EOF
>> void foo()
>> {
>> float f = 1.f;
>> float g = 0.f;
>> }
>> EOF
>>
>> $ vim -u NONE -c 'syntax on' foo.cpp
>>
>> Compare screenshots between vim-8.0.86 (bad)
>> and vim-7.4.1689 (good):
>>
>> http://dominique.pelle.free.fr/pic/bad-syntax-highlight-float-vim-8.0.86.png
>> http://dominique.pelle.free.fr/pic/good-syntax-highlight-float-vim-7.4.1689.png
>>
>> Bug happens with cpp files, but not with c files.
>>
>> I don't have time now to do a bisection to narrow
>> down when bug was introduced.
>
> Probably changed with one of the latest runtime updates.
> syntax/cpp.vib4ada79aa7d0d1e5da3a659b1a203d7cae9f7f59m
> was last changed here:
> https://github.com/vim/vim/commit/b4ada79aa7d0d1e5da3a659b1a203d7cae9f7f59
> and this looks suspicious, since it changes how cppNumber matches.
>
> Best,
> Christian
Hi Christian
I confirm that it's change b4ada79aa7d0d1e5da3a659b1a203d7cae9f7f59
that broke c++ syntax highlighting for floating point numbers:
===
commit b4ada79aa7d0d1e5da3a659b1a203d7cae9f7f59
Author: Bram Moolenaar <[email protected]>
Date: Sun Oct 30 21:55:26 2016 +0100
Runtime file updates.
===
Above change made the single quote digit separator
work for cppNumber, but it broke cFloat highlighting.
Attached patch fixes it.
I also see that support for single quote digit separator
(new in c++14) is done for cppNumber only. However,
single quote digit separator should normally also be
allowed for floating point numbers as well, and cpp vim
syntax file does not currently recognize that. For example,
vim does not properly highlight this line and my attached
patch does not fix that:
auto floating_point_literal = 0.000'015'3;
See examples of c++14 digit separators at:
https://en.wikipedia.org/wiki/C%2B%2B14#Digit_separators
Regards
Dominique
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/syntax/cpp.vim b/runtime/syntax/cpp.vim
index 5a478fb..37cbb1f 100644
--- a/runtime/syntax/cpp.vim
+++ b/runtime/syntax/cpp.vim
@@ -48,7 +48,7 @@ endif
if !exists("cpp_no_cpp14")
syn case ignore
syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
- syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
+ syn match cppNumber display "\<[1-9]\('\=\d\+\)\+\(u\=l\{0,2}\|ll\=u\)\>"
syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
syn case match
endif