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 option to ignore files outside of a workspace #532

Open
spok7 opened this issue Aug 14, 2024 · 0 comments
Open

Add option to ignore files outside of a workspace #532

spok7 opened this issue Aug 14, 2024 · 0 comments
Labels
feature-request Request for new features or functionality needs community feedback

Comments

@spok7
Copy link

spok7 commented Aug 14, 2024

Diagnostic Data

  • Python version (& distribution if applicable, e.g., Anaconda): 3.10.14 Anaconda 3
  • Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): conda 22.11.0
  • Operating system (and version): Ubuntu 20.04
  • Version of tool extension you are using: v2024.2.0

Behaviour

Consider the following user and workspace settings files:

.config/Code/User/settings.json

{    
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": false,
    },
    "black-formatter.args": [
        "--line-length",
        "80"
    ],
}

workspace/.vscode/settings.json

{
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true,
    },
    "black-formatter.args": [
        "--line-length",
        "120"
    ],
}

Expected Behavior

Extension uses workspace settings for all files. In this case, it formats on save and trims lines to 120 characters.

Actual Behavior

Extension uses workspace settings only when the file modified is within the workspace folder, otherwise it uses global settings. This is not ideal, because other settings don't work like this. The above settings result in other files outside the workspace being formatted on save with lines trimmed to 80 characters.

Possible Workarounds

  1. Changing the global settings to "args": ["--help"] would work, but it would then require every file to be in a workspace in order to format it.
  2. Disabling the workspace formatOnSave is not ideal when working on a project with strict formatting.

Ideal Solution

Add a way for disabling save formatting on files outside the workspace when workspace args are used.

Logs:

2024-08-14 17:13:16.801 [info] No interpreter found from setting black-formatter.interpreter
2024-08-14 17:13:16.801 [info] Getting interpreter from ms-python.python extension for workspace /home/user/Documents/IsaacLabExtensionTemplate
2024-08-14 17:13:16.803 [info] Interpreter from ms-python.python extension for /home/user/Documents/IsaacLabExtensionTemplate: /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/python.sh
2024-08-14 17:13:16.803 [info] Workspace settings for /home/user/Documents/IsaacLabExtensionTemplate (client side): {
    "cwd": "/home/user/Documents/IsaacLabExtensionTemplate",
    "workspace": "file:///home/user/Documents/IsaacLabExtensionTemplate",
    "args": [
        "--line-length",
        "120"
    ],
    "path": [],
    "interpreter": [
        "/home/user/.local/share/ov/pkg/isaac-sim-4.1.0/python.sh"
    ],
    "importStrategy": "useBundled",
    "showNotifications": "always"
}
2024-08-14 17:13:16.804 [info] Server: Stop requested
2024-08-14 17:13:16.804 [info] [Trace - 17:13:16] Sending request 'shutdown - (2)'.
2024-08-14 17:13:16.805 [info] [Trace - 17:13:16] Received response 'shutdown - (2)' in 1ms.
2024-08-14 17:13:16.805 [info] [Trace - 17:13:16] Sending notification 'exit'.
2024-08-14 17:13:16.806 [info] No interpreter found from setting black-formatter.interpreter
2024-08-14 17:13:16.806 [info] Getting interpreter from ms-python.python extension for workspace /home/user/Documents/IsaacLabExtensionTemplate
2024-08-14 17:13:16.808 [info] Interpreter from ms-python.python extension for /home/user/Documents/IsaacLabExtensionTemplate: /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/python.sh
2024-08-14 17:13:16.808 [info] Workspace settings for /home/user/Documents/IsaacLabExtensionTemplate (client side): {
    "cwd": "/home/user/Documents/IsaacLabExtensionTemplate",
    "workspace": "file:///home/user/Documents/IsaacLabExtensionTemplate",
    "args": [
        "--line-length",
        "120"
    ],
    "path": [],
    "interpreter": [
        "/home/user/.local/share/ov/pkg/isaac-sim-4.1.0/python.sh"
    ],
    "importStrategy": "useBundled",
    "showNotifications": "always"
}
2024-08-14 17:13:16.808 [info] Global settings (client side): {
    "cwd": "/home/user",
    "workspace": "/home/user",
    "args": [
        "--line-length",
        "80"
    ],
    "path": [],
    "interpreter": [],
    "importStrategy": "useBundled",
    "showNotifications": "always"
}
2024-08-14 17:13:16.809 [info] Server run command: /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/python.sh /home/user/.vscode/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_server.py
2024-08-14 17:13:16.809 [info] Server: Start requested.
2024-08-14 17:13:16.884 [info] [Error - 17:13:16] Server process exited with code 0.
2024-08-14 17:13:17.268 [info] CWD Server: /home/user/Documents/IsaacLabExtensionTemplate
2024-08-14 17:13:17.269 [info] Settings received on server:
[
    {
        "cwd": "/home/user/Documents/IsaacLabExtensionTemplate",
        "workspace": "file:///home/user/Documents/IsaacLabExtensionTemplate",
        "args": [
            "--line-length",
            "120"
        ],
        "path": [],
        "interpreter": [
            "/home/user/.local/share/ov/pkg/isaac-sim-4.1.0/python.sh"
        ],
        "importStrategy": "useBundled",
        "showNotifications": "always"
    }
]

2024-08-14 17:13:17.269 [info] Global settings received on server:
{
    "cwd": "/home/user",
    "workspace": "/home/user",
    "args": [
        "--line-length",
        "80"
    ],
    "path": [],
    "interpreter": [],
    "importStrategy": "useBundled",
    "showNotifications": "always"
}

2024-08-14 17:13:17.269 [info] sys.path used to run Server:
   /home/user/.vscode/extensions/ms-python.black-formatter-2024.2.0/bundled/libs
   /home/user/.vscode/extensions/ms-python.black-formatter-2024.2.0/bundled/tool
   /home/user/catkin_ws/devel/lib/python3/dist-packages
   /opt/ros/noetic/lib/python3/dist-packages
   /home/user
   /home/user/slim
   /home/user/.local/share/home/user/catkin_ws/devel/lib/python3/dist-packages
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/kit/python/lib/python3.10/site-packages
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/python_packages
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/exts/omni.isaac.kit
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/exts/omni.isaac.gym
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/kit/kernel/py
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/kit/plugins/bindings-python
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/exts/omni.isaac.lula/pip_prebundle
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/exts/omni.exporter.urdf/pip_prebundle
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/kit/exts/omni.kit.pip_archive/pip_prebundle
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/exts/omni.isaac.core_archive/pip_prebundle
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/exts/omni.isaac.ml_archive/pip_prebundle
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/exts/omni.pip.compute/pip_prebundle
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/exts/omni.pip.cloud/pip_prebundle
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/kit/python/lib/python310.zip
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/kit/python/lib/python3.10
   /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/kit/python/lib/python3.10/lib-dynload
   /home/user/Documents/IsaacLab/source/extensions/omni.isaac.lab_assets
   /home/user/Documents/IsaacLab/source/extensions/omni.isaac.lab
   /home/user/Documents/IsaacLab/source/extensions/omni.isaac.lab_tasks
2024-08-14 17:13:17.271 [info] /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/python.sh -m black --version
2024-08-14 17:13:17.271 [info] CWD formatter: /home/user/Documents/IsaacLabExtensionTemplate
2024-08-14 17:13:17.421 [info] Version info for formatter running for /home/user/Documents/IsaacLabExtensionTemplate:
black, 24.3.0 (compiled: no)
Python (CPython) 3.10.14

2024-08-14 17:13:17.421 [info] SUPPORTED black>=22.3.0
FOUND black==24.3.0

2024-08-14 17:13:20.191 [info] [Trace - 17:13:20] Sending request 'textDocument/formatting - (1)'.
2024-08-14 17:13:20.194 [info] [Trace - 17:13:20] Received notification 'window/logMessage'.
2024-08-14 17:13:20.195 [info] /home/user/.local/share/ov/pkg/isaac-sim-4.1.0/kit/python/bin/python3 -m black --line-length 80 --stdin-filename /home/user/Documents/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/sim/__init__.py -
2024-08-14 17:13:20.195 [info] [Trace - 17:13:20] Received notification 'window/logMessage'.
2024-08-14 17:13:20.195 [info] CWD formatter: /home/user/Documents/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/sim
2024-08-14 17:13:20.278 [info] [Trace - 17:13:20] Received notification 'window/logMessage'.
2024-08-14 17:13:20.278 [info] reformatted /home/user/Documents/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/sim/__init__.py

All done! ✨ 🍰 ✨
1 file reformatted.

2024-08-14 17:13:20.280 [info] [Trace - 17:13:20] Received response 'textDocument/formatting - (1)' in 89ms.
2024-08-14 17:13:20.288 [info] [Trace - 17:13:20] Sending notification 'textDocument/didChange'.
@spok7 spok7 added the bug Issue identified by VS Code Team member as probable bug label Aug 14, 2024
@github-actions github-actions bot added the triage-needed Issue is not triaged. label Aug 14, 2024
@karthiknadig karthiknadig self-assigned this Aug 15, 2024
@karthiknadig karthiknadig changed the title Inconsistent formatting on files outside of currently open folder. Add option to ignore files outside of a workspace Aug 15, 2024
@karthiknadig karthiknadig removed bug Issue identified by VS Code Team member as probable bug triage-needed Issue is not triaged. labels Aug 15, 2024
@karthiknadig karthiknadig removed their assignment Aug 15, 2024
@karthiknadig karthiknadig added feature-request Request for new features or functionality needs community feedback labels Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality needs community feedback
Projects
None yet
Development

No branches or pull requests

2 participants