Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Add to Workspace Recommendations" works incorrectly, when extension id has upper case. #164458

Closed
lclancey opened this issue Oct 24, 2022 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug extensions Issues concerning extensions insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@lclancey
Copy link

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

  • VS Code Version:
    1.72.2
  • OS Version:
    MacOS Monterey 12.3.1

Steps to Reproduce:

  1. Open any directory or workspace, empty directory in the video below for example.
  2. In Extensions tab, search "volar", then add first two extensions, Vue Language Features(Volar) and TypeScript Vue Plugin(Volar) into workspace recommendations.
  3. Bug: Every time you try to add one of these two extensions, the newly added extension id in ./vscode/extensions.json is a string start with a upper case like "Vue.xxx", and the rest of others will change to all lower case string like "volar.xxx", this makes further "Add to Workspace Recommendations" oprations work incorrectly.
2022-10-24.20.48.27.mov

My guessing:
The function getRecommendations and getUnwantedRecommendations returns an array of lowercase strings,

async getRecommendations(): Promise<string[]> {
const configs = await this.getExtensionsConfigs();
return distinct(flatten(configs.map(c => c.recommendations ? c.recommendations.map(c => c.toLowerCase()) : [])));
}
async getUnwantedRecommendations(): Promise<string[]> {
const configs = await this.getExtensionsConfigs();
return distinct(flatten(configs.map(c => c.unwantedRecommendations ? c.unwantedRecommendations.map(c => c.toLowerCase()) : [])));
}

however those adding or removing functions only push the raw extensionId to config file, which causes this bug when the raw extensionId has upper case.
private async addOrRemoveWorkspaceFolderRecommendation(extensionId: string, workspaceFolder: IWorkspaceFolder, extensionsConfigContent: IExtensionsConfigContent, add: boolean): Promise<void> {
const values: IJSONValue[] = [];
if (add) {
values.push({ path: ['recommendations'], value: [...extensionsConfigContent.recommendations || [], extensionId] });
if (extensionsConfigContent.unwantedRecommendations && extensionsConfigContent.unwantedRecommendations.some(e => e === extensionId)) {
values.push({ path: ['unwantedRecommendations'], value: extensionsConfigContent.unwantedRecommendations.filter(e => e !== extensionId) });
}
} else if (extensionsConfigContent.recommendations) {
values.push({ path: ['recommendations'], value: extensionsConfigContent.recommendations.filter(e => e !== extensionId) });
}
if (values.length) {
return this.jsonEditingService.write(workspaceFolder.toResource(EXTENSIONS_CONFIG), values, true);
}
}

@sandy081
Copy link
Member

I am not sure what the bug is here? Since extension ids are case insensitive, we handle them correctly while reading or writing. Can you please let us know what feature is not working?

@sandy081 sandy081 added the info-needed Issue requires more information from poster label Oct 24, 2022
@lclancey
Copy link
Author

I am not sure what the bug is here? Since extension ids are case insensitive, we handle them correctly while reading or writing. Can you please let us know what feature is not working?

Well, a simple description: you can click Add to Workspace Recommendations twice when adding vue.volar...the first time it will add "Vue.volar" string and second time "vue.volar".

Screen.Recording.2022-10-24.at.11.59.16.PM.mov

@sandy081
Copy link
Member

Got it. Thanks for providing info.

@sandy081 sandy081 added bug Issue identified by VS Code Team member as probable bug extensions Issues concerning extensions and removed info-needed Issue requires more information from poster labels Oct 24, 2022
@sandy081 sandy081 added this to the October 2022 milestone Oct 24, 2022
sandy081 added a commit that referenced this issue Oct 26, 2022
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Oct 26, 2022
formigoni pushed a commit to formigoni/vscode that referenced this issue Oct 27, 2022
@lramos15 lramos15 added the verified Verification succeeded label Oct 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug extensions Issues concerning extensions insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants