From b9b208860cbe480d3cc6190e2834444a27e92956 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Wed, 8 Feb 2023 22:04:08 +0300 Subject: [PATCH] Fix scan for empty build profiles containing only names These profiles can be created as `qbs-config profiles.empty undefined`, and they looks like: ... profiles.empty: undefined ... e.g. when the `qbs-config --list` called. Task-number: #71 --- CHANGELOG.md | 3 +++ src/qbsbuildprofilemanager.ts | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 705e328..a0518ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Implemented parsing for MSVC linker errors as diagnostic problems. - Improved parsing for IAR EW toolchain errors as diagnostic problems. +- [#71](https://github.com/denis-shienkov/vscode-qbs/issues/71) +Fixed scanning for empty build profiles (e.g. created as +`qbs-config profiles.empty undefined`). ## 2.1.0 diff --git a/src/qbsbuildprofilemanager.ts b/src/qbsbuildprofilemanager.ts index 096fb37..9751fa0 100644 --- a/src/qbsbuildprofilemanager.ts +++ b/src/qbsbuildprofilemanager.ts @@ -170,7 +170,7 @@ export class QbsBuildProfileManager implements vscode.Disposable { } } - const matches = /^profiles.(.+):\s"(.+)"$/.exec(line); + const matches = /^profiles.(.+):\s(.+)$/.exec(line); if (matches) { // Builds the data map in a backwards order from the path parts array. const createData = (parts: any): any => { @@ -214,6 +214,20 @@ export class QbsBuildProfileManager implements vscode.Disposable { const data = createData(parts); profileData = mergeData(profileData, data); } + } else if (parts && (parts.length === 1)) { + // E.g. for an empty profiles, created as `qbs-config profiles.empty undefined`, + // and listed with `qbs-config --list` as: + // ... + // profiles.empty: undefined + // ... + const name = parts[0]; + if (name !== profileName) { + // New profile started, commit the current profile. + if (profileName) + profiles.push(new QbsProtocolProfileData(profileName, profileData)); + profileName = name; + profileData = value; + } } } });