Description
openedon Nov 2, 2019
Type: Debugger
Describe the bug
- OS and Version: Windows_NT x64 10.0.18362
- VS Code Version: 1.39.2
- C/C++ Extension Version: 0.26.1
- Other extensions you installed (and if the issue persists after disabling them): No other extensions are installed.
The extension cannot create the launch.json
file with a debug configuration if the locale is set to German. Trying to create such a configuration results in the error message Die Datei "launch.json" kann nicht im Ordner ".vscode" erstellt werden (Unexpected token $ in JSON at position 113).
, i.e. The file "launch.json" cannot be created in the directory ".vscode". The issue is only present if the launch.json
file doesn't exist already. If the file exists, the configuration is added but the template is no valid JSON.
To Reproduce
- Set the locale to German
- Open a C++ project without a launch.json file
- Hit
F5
- Select
C++ (GDB/LLDB)
orC++ (Windows)
- See error
Additional context
If the launch.json
file already exists the creation of new configurations works. The generated code looks as follows:
{
"name": "(Windows) Starten",
"type": "cppvsdbg",
"request": "launch",
"program": "Programmnamen eingeben, z. B. "${workspaceFolder}/a.exe"",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false
}
The program
value is no valid JSON because the quote marks are not escaped.
There are likely other strings facing the same problem. For example if I generate a configuration for gdb
the result contains
"setupCommands": [
{
"description": "Automatische Strukturierung und Einrückung für "gdb" aktivieren",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
This also contains unescaped quote marks which cause problems.
The simplest fix would probably be to add the necessary escapes, e.g. replace "Programmnamen eingeben, z. B. \"{0}\"",
with "Programmnamen eingeben, z. B. \\\"{0}\\\""
, or removing the quotes entirely (as in all other languages I checked).
I'd be willing to contribute a fix but as far as I can tell, the localization files are generated. So if someone can point me to the source of the generation I could create a PR.