typescript-vim icon indicating copy to clipboard operation
typescript-vim copied to clipboard

Negative floats are not matched correctly.

Open haynesgt opened this issue 7 years ago • 2 comments

In negative floats like -2.5 and -2.004E7, the decimal is not highlighted as part of the number. This is because there is no word boundary before '-', but a word boundary is expected. Here is a suggested fix, where the typescriptFloat pattern expects a word boundary after '-' instead of before it.

diff --git a/syntax/typescript.vim b/syntax/typescript.vim
index 4abaeed..1635dd4 100644
--- a/syntax/typescript.vim
+++ b/syntax/typescript.vim
@@ -72,7 +72,7 @@ syn region typescriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[g
 " syntax region typescriptStringS start=+'+ skip=+\\\\\|\\$'+ end=+'+ contains=typescriptSpecial,@htmlPreproc
 " syntax region typescriptRegexpString start=+/\(\*\|/\)\@!+ skip=+\\\\\|\\/+ end=+/[gim]\{,3}+ contains=typescriptSpecial,@htmlPreproc oneline
 " syntax match typescriptNumber /\<-\=\d\+L\=\>\|\<0[xX]\x\+\>/
-syntax match typescriptFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/
+syntax match typescriptFloat /-\=\<\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/
 " syntax match typescriptLabel /\(?\s*\)\@<!\<\w\+\(\s*:\)\@=/

 syn match typescriptDecorators /@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>/

haynesgt avatar Oct 17 '16 20:10 haynesgt

Thanks for the patch! I'll get that applied.

leafgarland avatar Oct 25 '16 23:10 leafgarland

Still seeing this after a Vundle :PluginUpdate

cguinnup avatar Apr 18 '17 18:04 cguinnup