Strange bug in PHP files with HTML and Emmet parser because conditionals are been mistaken as opening and/or closing tags
See original GitHub issueIssue Type: Bug
- Open or create a PHP file
- Type the following example code:
<?php
$looping = 1;
$while = [];
while ($looping <= 5) {
//here you can't use emmet or html! give it a try!
$while[] = $looping;
$looping++;
}
var_dump($while);
$looping = 5;
$while = [];
do {
$while[] = $looping;
$looping--;
} while ($looping >= 1);
var_dump($while);
//here you can use emmet and html
for ($i = 1; $i <= 10; ) {
//here you can't use emmet or html. give it a try!
}
Expected result: Emmet and HTML should continue working and the parser should correctly identify conditionals as not part of an opening or ending tag statement.
Tested without any extensions enabled. It is a core php bug in the editor.
Screenshots to illustrate the actual results with current stable version: Emmet and HTML parsing does not work after using the conditional, because it is trying to parse it as an opening tag
Here the parsing works, because the while and do-while have complement conditionals, thus opening and closing a tag, for the html parser
Just to make it more clear about the opening/closing tag described above
It is a parsing bug because it will resume working after typing the matched closing tag even in a comment
I love VSCode and it has been really productive in my daily PHP work. I hope the issue gets addressed and fixed. Thank you for your time and attention on reading this lengthy report.
VS Code version: Code 1.45.1 (5763d909d5f12fe19f215cbfdd29a91c0fa9208a, 2020-05-14T08:27:35.169Z) OS version: Windows_NT x64 10.0.18363
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i7-3770K CPU @ 3.50GHz (8 x 3492) |
GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: disabled_off protected_video_decode: unavailable_off rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled viz_display_compositor: enabled_on viz_hit_test_surface_layer: disabled_off_ok webgl: enabled webgl2: enabled |
Load (avg) | undefined |
Memory (System) | 11.95GB (7.36GB free) |
Process Argv | |
Screen Reader | no |
VM | 0% |
Extensions (4)
Extension | Author (truncated) | Version |
---|---|---|
vscode-intelephense-client | bme | 1.3.11 |
vscode-toggle-quotes | Bri | 0.3.2 |
path-autocomplete | ion | 1.13.6 |
google-fonts | lio | 0.0.1 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
The Emmet extension for VS Code is currently using @emmetio/html-matcher to parse the HTML document, and even the latest version of that completely skips HTML content within PHP tags.
I’ll flag this as an upstream issue, and until there is a better Emmet parser for PHP files I don’t see this issue being fixed for a while.
Just to provide a minimal example to drive home @weidmaster’s well observed bug.
Create temp.php as follows (retyping at the relevant points):
With that file I can reproduce @weidmaster’s bug, with extensions disabled, in VS Code
1.51.1.1.57.1.Edit: Corrected typo in VS Code version.