Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect syntax colouring of YAML multi-line values containing colons #83709

Closed
itowlson opened this issue Oct 31, 2019 · 3 comments
Closed
Assignees
Labels
upstream-issue-linked This is an upstream issue that has been reported upstream

Comments

@itowlson
Copy link

Issue Type: Bug

Note: This was originally reported on the Kubernetes extension at vscode-kubernetes-tools/vscode-kubernetes-tools#639, and traced upstream to the Red Hat YAML extension at redhat-developer/vscode-yaml#242, but it looks like it affects all YAML files even without those extensions being installed, and appears to be down to the VS Code built-in YAML highlighter at https://github.com/microsoft/vscode/blob/master/extensions/yaml/syntaxes/yaml.tmLanguage.json.

The syntax highlighting of multi-line values containing colon characters doesn't look right. For example, consider the following YAML:

foo:
  bar: |
    set_header 'Server: '
    set_header 'Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS'
    set_header 'Access-Control-Allow-Origin: https://snip'

Here's how this gets highlighted:

image

Note that the first line of the multiline value gets 'key' colouring (blue) up to the colon, then the closing quote and start of next line get 'value" (brown) colouring until the next quote, then key again until the colon, then value...

If I remove the colons, everything in the multi-line value is correctly coloured brown.

I tried this in an online YAML parser and it treated the multi-line section as a single value, so I think this should be valid - the colons shouldn't be being handled as key-value separators.

VS Code version: Code 1.39.2 (6ab5985, 2019-10-15T15:35:18.241Z)
OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz (4 x 2904)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.85GB (2.04GB free)
Process Argv
Screen Reader no
VM 22%
Extensions (10)
Extension Author (truncated) Version
gitlens eam 10.1.1
EditorConfig Edi 0.14.2
tslint eg2 1.0.44
vscode-peacock joh 3.1.6
vscode-docker ms- 0.8.1
vscode-kubernetes-tools ms- 1.0.6
remote-wsl ms- 0.39.9
azure-account ms- 0.8.6
azurerm-vscode-tools msa 0.8.0
vscode-yaml red 0.5.3
@alexr00
Copy link
Member

alexr00 commented Oct 31, 2019

Looks like this is the upstream issue textmate/yaml.tmbundle#17

@alexr00 alexr00 closed this as completed Oct 31, 2019
@alexr00 alexr00 added the upstream-issue-linked This is an upstream issue that has been reported upstream label Oct 31, 2019
@itowlson
Copy link
Author

itowlson commented Nov 4, 2019

The trouble with closing this as an upstream issue is that the last comment in that upstream issue is them requesting help from the VS Code team: "Since @infininight has kindly explained the issue in a very detailed way, maybe someone familiar with VSCode would be willing to take a look at it :) It seems we're stuck without some help. Sorry for tagging you out of the blue @alexandrudima @bpasero, is there a chance you could take a quick look at this issue (or tag someone who could)? Would be very much appreciated!" So it sounds like Code is waiting for a fix from upstream, while upstream is appealing to Code to do the fix!

How do we break this circle?

@alexr00
Copy link
Member

alexr00 commented Nov 5, 2019

From what I understand from textmate/yaml.tmbundle#17 (comment), this is a limitation of using textmate. There's not much to be done about that other than maybe #77140 will help.

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream-issue-linked This is an upstream issue that has been reported upstream
Projects
None yet
Development

No branches or pull requests

2 participants