microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 454 forks source link

`cmake.pinnedCommands` added automatically to settings #3977

Closed thernstig closed 2 days ago

thernstig commented 3 months ago

Brief Issue Summary

These settings gets automatically added to my VS Code settings.json when I open the JSON file and save it:

{
    "cmake.pinnedCommands": [
        "workbench.action.tasks.configureTaskRunner",
        "workbench.action.tasks.runTask"
    ]
}

Why does it do this?

I am using VS Code Profiles. This setting gets added to the profile settings. Not sure this matters, but adding it for context.

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.92.0",
  "cmtVersion": "1.18.44",
  "configurations": [
    {
      "folder": "/home/tobias/code/c-test",
      "cmakeVersion": "3.30.2",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": true,
      "compilers": {
        "C": "/usr/bin/gcc",
        "CXX": "/usr/bin/g++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "helloworld",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    }
  ]
}

Debug Log

[main] Configuring project: c-test 
[main] Saving open files before configure/build
[driver] Start configure 
[driver] Running pre-configure checks and steps
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake /usr/bin/cmake with arguments ["-DCMAKE_INSTALL_PREFIX=/home/tobias/code/c-test/out/install/foo","-DCMAKE_C_COMPILER=/usr/bin/gcc","-DCMAKE_CXX_COMPILER=/usr/bin/g++","-DCMAKE_BUILD_TYPE=Debug","-S/home/tobias/code/c-test","-B/home/tobias/code/c-test/out/build/foo"]
[proc] Executing command: /usr/bin/cmake -DCMAKE_INSTALL_PREFIX=/home/tobias/code/c-test/out/install/foo -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_BUILD_TYPE=Debug -S/home/tobias/code/c-test -B/home/tobias/code/c-test/out/build/foo
[proc]   with environment: {"FZF_CD_WITH_HIDDEN_COMMAND":"fd --type d --no-ignore-vcs --exclude .git --hidden","FZF_CD_COMMAND":"fd --type d --no-ignore-vcs --exclude .git","USER":"tobias","VSCODE_WSL_EXT_LOCATION":"/mnt/c/Users/siniz/.vscode/extensions/ms-vscode-remote.remote-wsl-0.88.2","FZF_PREVIEW_DIR_CMD":"ls","FZF_DEFAULT_OPTS":"--reverse --height 20% --inline-info","SSH_AGENT_PID":"19","HOME":"/home/tobias","NODE_VERSIONS":"/home/tobias/.local/share/nvm","WSL_DISTRO_NAME":"Ubuntu","NODE_VERSION_PREFIX":"v","WAYLAND_DISPLAY":"wayland-0","FZF_TMUX_HEIGHT":"40%","LOGNAME":"tobias","FZF_DISABLE_KEYBINDINGS":"0","PULSE_SERVER":"unix:/mnt/wslg/PulseServer","WSL_INTEROP":"/run/WSL/28368_interop","NAME":"DESKTOP-00IP01M","TERM":"xterm-256color","PATH":"/home/tobias/code/c-test/build:/home/tobias/.vscode-server/bin/b1c0a14de1414fcdaa400695b4db1c0799bc3124/bin/remote-cli:/home/tobias/.pyenv/bin:/home/tobias/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/WinMerge:/mnt/c/Users/siniz/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/siniz/AppData/Local/Programs/Microsoft VS Code/bin:/snap/bin","SSH_ENV":"/home/tobias/.ssh/environment","XDG_RUNTIME_DIR":"/mnt/wslg/runtime-dir","DISPLAY":":0","LANG":"C.UTF-8","SSH_AUTH_SOCK":"/tmp/ssh-FWTuAmlH4Yhy/agent.17","SHELL":"/usr/bin/fish","FZF_PREVIEW_FILE_CMD":"head -n 10","FZF_LEGACY_KEYBINDINGS":"0","FZF_FIND_FILE_COMMAND":"fd --type f --hidden --no-ignore-vcs --exclude .git","PWD":"/home/tobias/code","FZF_DEFAULT_COMMAND":"fd --type f --hidden --no-ignore-vcs --exclude .git","PIPENV_VENV_IN_PROJECT":"true","PYENV_ROOT":"/home/tobias/.pyenv","XDG_DATA_DIRS":"/usr/local/share:/usr/share:/var/lib/snapd/desktop","WSL2_GUI_APPS_ENABLED":"1","HOSTTYPE":"x86_64","WSLENV":"VSCODE_WSL_EXT_LOCATION/up","EDITOR":"code","VSCODE_CWD":"/home/tobias/code","VSCODE_NLS_CONFIG":"{\"userLocale\":\"en\",\"osLocale\":\"en\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"/home/tobias/.vscode-server/bin/b1c0a14de1414fcdaa400695b4db1c0799bc3124/out/nls.messages.json\",\"locale\":\"en\",\"availableLanguages\":{}}","VSCODE_HANDLES_SIGPIPE":"true","SHLVL":"1","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","ELECTRON_RUN_AS_NODE":"1","VSCODE_IPC_HOOK_CLI":"/mnt/wslg/runtime-dir/vscode-ipc-49a0389a-1a1f-483a-9105-c54b83690872.sock","DIRENV_DIFF":"eJzsU9tyujwQf5VOrqURxCrcodjPY6VSRXvDQFiVNiQ0CYp2-u7fYM_Ov9MX6BX5HXaBzf6eUY7sZ-Q5d31kI7zlGWDF4zSS-HInCU9AkyB2IHCcMhzrpB7pZgK6qZtrkkSRWa9fWc3YTCqpZVkxaeiGeTILyLgCjdDU_t43PwDbVZYznnIS0Ve-kAK_QnmGP-CncDq8wg9uE2Ugv9Z9JdIY7yWtnjbOmMIEB4Mbdxr4WB6kgqxhnPHnNv_NhoMYsp_FlCV8Lz2-B-FvgVK80y_r-Ef_NAfm-_0Pgyf4RkTZxXVKQVbdJiA28K7OJQiJZcrSI3by3I1UhMenX52kRHDJ1-r9C5w8l7-Xvb1OftZfLPyLLk_gbcIsyqsTeqkhVi2NO5j1bhahO5ghG2nf7rJaHEw0BVKh2rsxcO66_Z6PbATDUh6FPuq4vVtn2mlkyyfrkFjKmNZVZ1mU2ZBOjJ5bOI-P7c66n7RWlrVZhTuzXEM0u9o7ZUvlD5v4uuR87LPRwbot29G4MSuTlTkyaBCYo8JsTMHwZHN7b4Y-fXDVloXWKGwuDi29ez8ns-P8euHlwNobPXnSHslxMVzOs4CaLmkNmlt5u9WydHhjtNWTEQdjNxsSL46brDEh1BguXUewq1a3romjt3ecMLRG__VSimr_TNOXieC4SGli_4XtL2y_h62GvIFXpWd1So4SBaCXl_8DAAD__1G28VM=","DIRENV_DIR":"-/home/tobias/code/c-test","DIRENV_WATCHES":"eJxszr1KBDEQAOB3mXq9yd9t2O0tBXuxmJlM2EDuAkk8BfHd7Y99gY_v4xfeaR6wAx7tpjgbFxooLSnKy9Qx8aL3RxdY4K2lWW4Ku43Oe2Ps5hZ4_SljDthn_9K_5Vy71CZUcRzUFVPpen8g1dq-kczVJXUmWl4Dc7I5hsQh-miJN28tq2bWLDmJcPbb5n3Mcl2JXDArn67C0-rzPwAA__9KGEil","PIPENV_YES":"true","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","VSCODE_L10N_BUNDLE_LOCATION":""}
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: /home/tobias/code/c-test/out/build/foo
[cmakefileapi-parser] Read reply folder: /home/tobias/code/c-test/out/build/foo/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-2be09f2d7752dd05721c.json","cmakeFiles-v1-f27be08af34e2cdc2959.json","codemodel-v2-d7b61e3922b0cc03ab64.json","directory-.-Debug-f5ebdc15457944623624.json","index-2024-08-10T14-41-29-0941.json","target-helloworld-Debug-e13caa876d582b512ac2.json","toolchains-v1-4071897e80daad5f46f4.json"]
[cache] Reading CMake cache file /home/tobias/code/c-test/out/build/foo/CMakeCache.txt
[cache] Parsing CMake cache string
[cache] Reading CMake cache file /home/tobias/code/c-test/out/build/foo/CMakeCache.txt
[cache] Parsing CMake cache string

Additional Information

No response

v-frankwang commented 3 months ago

@thernstig The CMake: pinned commands setting is automatically added after installing the CMake Tools extension. If you resave the settings.json file with the CMake Tools extension disabled, the CMake: pinned commands setting will not be added automatically. Do you have any other questions? Looking forward to hearing from you!

thernstig commented 3 months ago

@v-frankwang yes, that is what I noticed, but that goes against every other extension I have seen. Why are you required to pollute our settings.json with settings I have not manually set? If anything, cmake.pinnedCommands should instead be the default.

Our own settings.json should only ever be manually edited or changed when I invoke commands in VS Code, but automatically like this, I am fairly certain this extension does something wrong doing it like that.

v-frankwang commented 3 months ago

@moyo1997 Customers do not manually add this configuration: cmake.pinnedCommands, this configuration is automatically added to the setting, json file, we will set the setting.json file in this configuration after deleting and re-saving, this configuration will be automatically added again. I tried to remove this configuration in the settings UI and it doesn't work. If I add this setting to the Workspace setting, it doesn't happen in the User setting. I'm not sure if this is happening because cmake tools itself is designed this way or if it's a problem, can you give me some advice? Looking forward to hearing from you!

image

thernstig commented 3 months ago

@v-frankwang exactly, that is what this issue is about. CMake Tools should not add settings on save automatically to any settings.json file.

v-frankwang commented 3 months ago

@moyo1997 Customers do not manually add this configuration: cmake.pinnedCommands, this configuration is automatically added to the setting, json file, we will set the setting.json file in this configuration after deleting and re-saving, this configuration will be automatically added again. I tried to remove this configuration in the settings UI and it doesn't work. If I add this setting to the Workspace setting, it doesn't happen in the User setting. I'm not sure if this is happening because cmake tools itself is designed this way or if it's a problem, can you give me some advice? Looking forward to hearing from you!

image

@gcampbell-msft I've reproduced the user's problem, but not not sure if it's a bug or not, can you give me some advice about this? Looking forward to receiving your reply!

gcampbell-msft commented 3 months ago

@v-frankwang @thernstig This sounds like a possible bug and something that we should investigate. Thank you for bringing it to our attention!

moyo1997 commented 2 months ago

@gcampbell-msft Correct there is a bug. Those particular settings are designed to auto populate in the settings file as part of this support: https://github.com/microsoft/vscode-cmake-tools/pull/3690/files#top. However, if one deletes this section and saves the settings file, it should respect it and not re-add it.

thernstig commented 2 months ago

@moyo1997 I'm an avid user of many extensions for multiple programming languages, and afaik it is good design that extensions never populate any settings.json files (workspace, user, profile, remote etc.) automatically. A user should do some action for that to happen. If defaults are wanted they should stay as defaults in the default settings.json.

moyo1997 commented 2 months ago

@thernstig thank you! We'll work on addressing this issue.

githubuser6000 commented 2 months ago

Can reproduce. What does this setting do again? The description is not at all clear.

thernstig commented 2 months ago

@githubuser6000 if you open the CMake sidebar (click the CMake extension's icon in the activity bar) there is a section there showing pinned commands.

Though I completely agree the description is not clear, and should be re-written. Possibly write a new issue about it?

v-frankwang commented 2 months ago

@thernstig Thank you very much for your comment! The place you mentioned is where you can pinned some common cmake commands, you can click run command after the pinned command to run these commands directly. I'm not sure what you're talking about when you say the description is unclear, can you elaborate?

githubuser6000 commented 1 month ago

@githubuser6000 if you open the CMake sidebar (click the CMake extension's icon in the activity bar) there is a section there showing pinned commands.

ooOOOoohhhh yea I see it, thanks!

thernstig commented 1 month ago

@v-frankwang the description is unclear. It says:

// List of CMake commands to pin.

How would one know where it is pinned and why it is good to use it? If it said something like:

"List of CMake commands to pin in the CMake Tools sidebar section "PINNED COMMANDS"

It would have given:

There could also be an example text as to why one would maybe want to pin commands, but that is a stretch. Something like "Example: Add cmake.X to make it show up as a quick way to access this command from the sidebar".

My opinion is that the entire feature could be removed 😆 One can always write ctrl+shift+p and type the command which is arguably faster. This is VS Code's default way to run any command. I have never seen any other extension have a special, dedicated area to add commands specifically for that extension.

v-frankwang commented 1 month ago

@gcampbell-msft The user felt that we didn't describe this feature very well, and he felt that it could all be removed because it might be faster for the user to write and type the commands themselves at any time. Can you give some suggestions?

gcampbell-msft commented 1 month ago

@thernstig Thanks for the feedback. We can definitely take a note to update our documentation for the feature. We will continue to track this issue for the issue of adding automatically to settings.

@moyo1997 FYI.