microsoft / microsoft/vscode

PHP syntax highlighting breaks in embedded SQL strings with unmatched [ after escaped quote

Open
#332,897 0 comments 0 reactions 1 assignee Claimed by @hediet View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

VSCode appears to detect SQL statements inside PHP strings when the string starts with an SQL keyword such as `SELECT`, `UPDATE`, `INSERT`, or `DELETE`. An unmatched `[` inside such an embedded SQL string causes syntax highlighting to remain in an incorrect state after the PHP string has ended.

```
$fetch = DB::query('SELECT id FROM mytable WHERE myfield LIKE \'%[search_word%\'')->execute();
```

Image

These work correctly:
```
$x = '\'%[abcdef\'';
$x = 'SELECT \'%[abcdef%]\'';
$x = 'SELECT "%[abcdef"';
```
This does not:
```
$x = 'SELECT \'%[abcdef\'';
```

Does this issue occur when all extensions are disabled?: Yes

Version: 1.136.0-insider (user setup)
Commit: 222818cc1d871f299b909604ea267e955182d2a4
Date: 2026-08-26T11:28:05Z
Electron: 42.8.1
ElectronBuildId: 14906494
Chromium: 148.0.7778.280
Node.js: 24.18.1
V8: 14.8.178.38-electron.0
@github/copilot: 1.0.81-0
@github/copilot-sdk: 1.0.11
OS: Windows_NT x64 10.0.26200

Steps to Reproduce:

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.