redhat-developer / vscode-yaml

YAML support for VS Code with built-in kubernetes syntax support
MIT License
652 stars 221 forks source link

Single dot shows as a float while it's a string #1039

Open karelbilek opened 2 months ago

karelbilek commented 2 months ago

Describe the bug

When a single dot is a value in key/value map, it is shown as a float while YAML parses it as a string

Expected Behavior

The dot has highlight as a string

Current Behavior

The dot has highlight as a float

Steps to Reproduce

paths:
  etc: /etc
  pwd: .
  number: 3
  up: ./..
Screenshot 2024-07-11 at 7 37 30

. should be highlighted as a string, not as a number. Because YAML will parse it as a string. This parsed as a JSON is:

{
  "paths": {
    "etc": "/etc",
    "pwd": ".",
    "number": 3,
    "up": "./.."
  }
}

Environment

karelbilek commented 2 months ago

. gets YAML parsed as a string, shows in extension as float (incorrect)

.3 gets YAML parsed as a float, shows in extension as float (correct)

..3 gets YAML parsed as a string, shows in extension as float (incorrect)

karelbilek commented 2 months ago
one: .
two: .3
three: ..3
Screenshot 2024-07-11 at 7 42 20
{
  "one": ".",
  "two": 0.3,
  "three": "..3"
}