Skip to content

String arrays in env are not joined properly #5509

@kersson

Description

@kersson

Type: LanguageService

Describe the bug

  • OS and Version: macOS 10.15.4
  • VS Code Version: 1.45.1
  • C/C++ Extension Version: 0.28.0

In #5229 environment variables were changed to be split using a platform-specific delimiter (; on Windows and : for everything else, like Linux and macOS). However, joining arrays of strings in the env variable in c_cpp_properties.json was not properly updated to match this new behavior, causing such variables to be incorrectly parsed when substituted in configurations.

This causes bugs like lists of include directories to not resolve properly when used in multiple configurations on non-Windows machines.

Steps to reproduce

  1. Add a variable containing an array of strings to the env section of c_cpp_properties.json.
  2. Reference this variable in a configuration.
{
    "env": {
        "commonIncludes": [
            "${workspaceFolder}/path/to/dir1",
            "${workspaceFolder}/path/to/dir2"
        ]
    },
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${commonIncludes}"
            ]
        }
    ],
    "version": 4
}

Incorrect behavior

-------- Diagnostics - 5/15/2020, 10:07:43 PM
Version: 0.28.0
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "${workspaceFolder}/path/to/dir1;${workspaceFolder}/path/to/dir2"
    ],
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}/path/to/dir1;${workspaceFolder}/path/to/dir2",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
No active translation units.

Expected behavior

-------- Diagnostics - 5/15/2020, 10:09:10 PM
Version: 0.27.1
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "${workspaceFolder}/path/to/dir1",
        "${workspaceFolder}/path/to/dir2"
    ],
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}/path/to/dir1",
            "${workspaceFolder}/path/to/dir2",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
No active translation units.

Metadata

Metadata

Assignees

Labels

Feature: ConfigurationAn issue related to configuring the extension or IntelliSenseLanguage ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.regressionA bug that didn't exist in a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions