Skip to content

C++ syntax highlighting falls apart #202365

@akbyrd

Description

@akbyrd

Type: Bug

Syntax highlighting for this snippet is very incorrect. It appears to get into a confused state and basically everything about it is wrong. Once it occurs in a file everything after that point shows up as a string, which as you can imagine is pretty jarring.

struct foo
{
	void (*bar1)() noexcept;
	void (*bar2)() noexcept;
	void (*bar3)() noexcept;
};

void baz()
{
	static_assert(false, "some string");
	int x = 0;
}

In latest insiders with the default theme
image

More issues are apparent depending on the theme being used
image

Here's the snippet again with some of the issues annotated. It appears as though the parser gets confused on the first function pointer and essentially thinks all the things after it are parameters in the function pointer type.

struct foo
{
    void (*bar1)() noexcept;        // noexcept is entity.name.type.parameter, should be storage.modifier.special.functional.post-parameters.noexcept.cpp
    void (*bar2)() noexcept;        // bar2 is variable.parameter.pointer.function, should be variable.other.pointer.function.cpp
    void (*bar3)() noexcept;
};                                  // } is meta.parameter.cpp, should be punctuationsection.block.end.bracket.curly.struct.cpp

void baz()                          // baz is entity.name.type.parameter.cpp, should be entity.name.function.definition.cpp
{
    static_assert(false, "string");
    int x = 0;                      // line is string.quoted.double.cpp
}

VS Code version: Code - Insiders 1.86.0-insider (29bef56, 2024-01-12T05:37:28.770Z)
OS version: Windows_NT x64 10.0.22621
Modes:

System Info
Item Value
CPUs AMD Ryzen Threadripper PRO 3945WX 12-Cores (24 x 3993)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 63.86GB (36.74GB free)
Process Argv --crash-reporter-id 2860e056-a3df-4573-a10a-18ca229997c6
Screen Reader no
VM 0%
Extensions: none
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vscod805cf:30301675
vsaa593:30376534
py29gd2263:30784851
vscaat:30438846
vsclangdf:30492506
c4g48928:30535728
a9j8j154:30646983
pythongtdpath:30726887
i26e3531:30792625
welcomedialog:30812478
pythonidxpt:30768918
pythonnoceb:30776497
asynctok:30898717
dsvsc013:30777762
dsvsc014:30777825
dsvsc015:30821418
pythontestfixt:30866404
pythonregdiag2:30926734
pyreplss1:30879911
pythonmypyd1:30859725
pythoncet0:30859736
pythontbext0:30879054
accentitlementst:30870582
dsvsc016:30879898
dsvsc017:30880771
dsvsc018:30880772
aa_t_chat:30882232
14951562:30934201

Metadata

Metadata

Assignees

Labels

grammarSyntax highlighting grammarupstream-issue-linkedThis is an upstream issue that has been reported upstream

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions