vscode-textmate icon indicating copy to clipboard operation
vscode-textmate copied to clipboard

yaml highlighting/textmate recognises some integers as strings (or vice versa?)

Open pedroterzero opened this issue 3 years ago • 1 comments

Some integers (or strings?) are treated differently even though they look the same to me.

In each comment I've specified what the scope inspector reports the scope as.

Testcase:

test:
  - test: 01 # constant.numeric.integer.yaml
  - test: 02 # constant.numeric.integer.yaml
  - test: 03 # constant.numeric.integer.yaml
  - test: 04 # constant.numeric.integer.yaml
  - test: 05 # constant.numeric.integer.yaml
  - test: 06 # constant.numeric.integer.yaml
  - test: 07 # constant.numeric.integer.yaml
  - test: 08 # string.unquoted.plain.out.yaml
  - test: 09 # string.unquoted.plain.out.yaml
  - test: 10 # constant.numeric.integer.yaml

This is what it ends up looking like for me: Screenshot from 2022-02-17 19-34-06

I'd expect them all to be the same; so either they should all be integers or they should all be unquoted strings. Right?

pedroterzero avatar Feb 17 '22 18:02 pedroterzero

The check for base 10 numbers does not allow for prefixing 0's [-+]? (?: 0|[1-9][0-9_]*) # (base 10) https://github.com/textmate/yaml.tmbundle/blob/e54ceae3b719506dba7e481a77cea4a8b576ae46/Syntaxes/YAML.tmLanguage#L807

cases 00 - 07 are handled by the base 8 regex [-+]? 0 [0-7_]+ # (base 8) which can also handle infinite prefixed 0's https://github.com/textmate/yaml.tmbundle/blob/e54ceae3b719506dba7e481a77cea4a8b576ae46/Syntaxes/YAML.tmLanguage#L806

https://github.com/microsoft/vscode/blob/c4e1f19aac0ef025ec208bc5d6500df5e5e36600/extensions/yaml/syntaxes/yaml.tmLanguage.json#L460

Move to: https://github.com/textmate/yaml.tmbundle/issues/39

RedCMD avatar Apr 28 '22 00:04 RedCMD