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

Enable 'powershell.scriptAnalysis.settingsPath' to search project root in multi-root workspaces #4743

Open
2 tasks done
steakhutzeee opened this issue Sep 17, 2023 · 6 comments
Assignees
Labels
Area-Script Analysis Issue-Enhancement A feature request (enhancement).

Comments

@steakhutzeee
Copy link

steakhutzeee commented Sep 17, 2023

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.

Summary

Hello,

as i can see, the option powershell.scriptAnalysis.settingsPath can only be set globally or per workspace.

I'm actually using multi-root workspaces and so i should edit the setting every time i switch the folder.

Could be possible to implement a way to search for the PSScriptAnalyzerSettings.psd1 file in the project root and so on, in order to have one different setting file per folder in a multi-root workspace?

Default value set in #2190 does nothing. Setting file is not read from any of my directories in the workspace.

Thank you!

Proposed Design

No response

@steakhutzeee steakhutzeee added the Issue-Enhancement A feature request (enhancement). label Sep 17, 2023
@lewis-yeung
Copy link

Agreed. It will bring great convenience if this can be implemented.

@andyleejordan
Copy link
Member

Oh is that what's going on. To be honest I've been meaning to investigate this setting because it looked broken to me...I was in a multi-root repo! Yes, we'll get this fixed. Probably the most backwards compatible algorithm is to check each folder as if it were root, stopping with the first found file (and starting with the first listed folder).

@andyleejordan andyleejordan self-assigned this Jun 3, 2024
@andyleejordan
Copy link
Member

Ok so I started working on this but:

Could be possible to implement a way to search for the PSScriptAnalyzerSettings.psd1 file in the project root and so on, in order to have one different setting file per folder in a multi-root workspace?

I'm not sure how viable this is. This specifically being per-workspace-folder PSSA settings. The extension is just one process for the whole workspace, which means one analysis service and therefore one PSSA being hosted. I think it's going to have to remain one PSSA settings file per workspace.

What I can fix is the ability to find that file in any (the first where it exists) of the workspace folders. Would that help? I checked and it as of now, if it's in the first workspace folder of a multi-root workspace, it's found. That just doesn't work if it's instead in a second or beyond folder.

I also tested just to be sure and unfortunately the syntax of ${workspaceFolder:<some named folder>} doesn't work in a workspace settings file.

@lewis-yeung
Copy link

lewis-yeung commented Jul 17, 2024

The extension is just one process for the whole workspace, which means one analysis service and therefore one PSSA being hosted.

unfortunately the syntax of ${workspaceFolder:<some named folder>} doesn't work in a workspace settings file.

@andyleejordan So, I guess the limitation is that ${workspaceFolder:<folderName>} cannot be expanded as expected for path resolution in the VS Code extension, under the restriction of the singleton service, right? Anyway, thank you for trying to fix it.

@andyleejordan
Copy link
Member

@lewis-yeung that's correct.

What I can fix is the ability to find that file in any (the first where it exists) of the workspace folders. Would that help? I checked and it as of now, if it's in the first workspace folder of a multi-root workspace, it's found. That just doesn't work if it's instead in a second or beyond folder.

Would this still be an improvement for you? If so I can get PowerShell/PowerShellEditorServices#2167 into the next release.

@lewis-yeung
Copy link

Would this still be an improvement for you? If so I can get PowerShell/PowerShellEditorServices#2167 into the next release.

Seems there is no perfect solution for the time being, but that would help somewhat, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Script Analysis Issue-Enhancement A feature request (enhancement).
Projects
Status: Todo
Development

No branches or pull requests

4 participants