Skip to content

Commit 7389d35

Browse files
fix: Fix an extension activation when api proposal comes with version, like: chatSessionsProvider@3
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent 3234130 commit 7389d35

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**********************************************************************
2+
* Copyright (c) 2026 Red Hat, Inc.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
***********************************************************************/
10+
11+
import { ApiProposalName, allApiProposals } from "../../../../../platform/extensions/common/extensionsApiProposals.js";
12+
import { ILogService } from "../../../../../platform/log/common/log.js";
13+
14+
/* eslint-disable header/header */
15+
16+
function normalizeProposedApiName(name: string): ApiProposalName {
17+
const match = /^(.+?)@\d+$/.exec(name);
18+
return (match ? match[1] : name) as ApiProposalName;
19+
}
20+
21+
export function normalizeAndFilterProposals(
22+
logService: ILogService,
23+
key: string,
24+
proposals: readonly string[]
25+
): ApiProposalName[] {
26+
const normalizedProposals: ApiProposalName[] = [];
27+
for (const name of proposals) {
28+
const normalizedName = normalizeProposedApiName(name);
29+
const result = Boolean(allApiProposals[normalizedName]);
30+
if (!result) {
31+
logService.error(`Extension '${key}' wants API proposal '${name}' but that proposal DOES NOT EXIST. Likely, the proposal has been finalized (check 'vscode.d.ts') or was abandoned.`);
32+
continue;
33+
}
34+
if (!normalizedProposals.includes(normalizedName)) {
35+
normalizedProposals.push(normalizedName);
36+
}
37+
}
38+
return normalizedProposals;
39+
}

code/src/vs/workbench/services/extensions/common/extensionsProposedApi.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { IWorkbenchEnvironmentService } from '../../environment/common/environme
1616
import { Extensions, IExtensionFeatureMarkdownRenderer, IExtensionFeaturesRegistry, IRenderedData } from '../../extensionManagement/common/extensionFeatures.js';
1717
import { IMarkdownString, MarkdownString } from '../../../../base/common/htmlContent.js';
1818
import { Mutable } from '../../../../base/common/types.js';
19+
import { normalizeAndFilterProposals } from './che/extensions.js';
1920

2021
export class ExtensionsProposedApi {
2122

@@ -67,13 +68,7 @@ export class ExtensionsProposedApi {
6768

6869
// warn about invalid proposal and remove them from the list
6970
if (isNonEmptyArray(extension.enabledApiProposals)) {
70-
extension.enabledApiProposals = extension.enabledApiProposals.filter(name => {
71-
const result = Boolean(allApiProposals[<ApiProposalName>name]);
72-
if (!result) {
73-
this._logService.error(`Extension '${key}' wants API proposal '${name}' but that proposal DOES NOT EXIST. Likely, the proposal has been finalized (check 'vscode.d.ts') or was abandoned.`);
74-
}
75-
return result;
76-
});
71+
extension.enabledApiProposals = normalizeAndFilterProposals(this._logService, key, extension.enabledApiProposals);
7772
}
7873

7974

0 commit comments

Comments
 (0)