ansible / vscode-ansible

vscode/vscodium extension for providing Ansible auto-completion and integrating quality assurance tools like ansible-lint, ansible syntax check, yamllint, molecule and ansible-test.
https://ansible.readthedocs.io/projects/vscode-ansible/
MIT License
360 stars 86 forks source link

ansible.lightspeed.enabled setting is not applied if it's declared in .vscode/settings.json file in multi-root workspace #1443

Open svor opened 2 months ago

svor commented 2 months ago

Summary

I have a multi-root workspace (in Dev Spaces it is a default state), I'd like to automatically enable Ansible Lightspeed, for this I've added "ansible.lightspeed.enabled": true into .vscode/settings.json file. It means that this setting was applied on Workspace Folder level but it's not enough to enable Ansible Lightspeed:

screenshot-nimbusweb me-2024 07 23-11_44_30

Would it be possible to check if ansible.lightspeed.enabled was set in Workspace Folder settings level to apply it?

Steps to reproduce on VS Code: 1/ Open any project and create .vscode/settings.json file with the content:

{
    "ansible.lightspeed.enabled": true
}

2/ Add another project to the workspace File -> Add Folder to Workspace 3/ Check that Ansible Lightspeed is not enabled

Extension version

v24.8.3

VS Code version

1.91.0

Ansible Version

ansible [core 2.16.6]
  config file = None
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.11/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections:/projects/ansible-devspaces-demo/collections
  executable location = /usr/local/bin/ansible
  python version = 3.11.5 (main, Sep 22 2023, 15:34:29) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/usr/bin/python3.11)
  jinja version = 3.1.4
  libyaml = True

OS / Environment

NAME="Red Hat Enterprise Linux" VERSION="8.9 (Ootpa)" ID="rhel" ID_LIKE="fedora" VERSION_ID="8.9"

ansible-lint 24.2.3

Relevant log output

No response

TamiTakamiya commented 2 months ago

Currently we check if Lightspeed is enabled or not using the logic like:

    const lightspeedSettings = <LightSpeedServiceSettings>(
      vscode.workspace.getConfiguration("ansible").get("lightspeed")
    );
    const lightspeedEnabled = lightspeedSettings?.enabled;

i.e. we are using the "non-scoped" getConfiguration and it should be the reason that the Workspace Folder-level settings are not picked up (reference).

In order to supporting Workspace Folder-level settings, just updating the "non-scoped" getConfiguration to the "scoped" one in this logic would not be enough. There are other settings retrieved in the same way and at least Lightspeed-related ones likely need to be updated. Also we need to implement corresponding UI changes, for example the Ansible Lightspeed view on the sidebar needs to change contents displayed depending on the current workspace folder that the current file opened in the editor.

I think we'd better handle this as a new feature rather than a bug. @ssbarnea what do you think?