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

Unable to specify clang-format file:${workspaceFolder} for multi-root workspace #10752

Closed
jlj-ee opened this issue Mar 28, 2023 · 4 comments
Closed
Assignees
Labels
bug Feature: Code Formatting Feature: Multi-root fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@jlj-ee
Copy link

jlj-ee commented Mar 28, 2023

Environment

  • OS and Version: Windows 10.0.19045
  • VS Code Version: 1.73.1
  • C/C++ Extension Version: 1.14.5

Bug Summary and Steps to Reproduce

Bug Summary:
Setting clang-format via file:${workspaceFolder} works well per #9786.
However, using the standard multi-root workspace syntax file:${workspaceFolder:someOtherFolder} causes the path to no longer be expanded, e.g.
ms-vscode.cpptools-1.14.5-win32-x64/bin/../LLVM/bin/clang-format.exe -style=file:${workspaceFolder:common}/.clang-format

Per the multi-root workspace docs

It is possible to scope a variable per workspace folder by appending the root folder's name to a variable (separated by a colon)

While I can work around this by using the actual relative/absolute path instead of ${workspaceFolder:someOtherFolder}, the multi-root scoping syntax works fine in other places in this extension, e.g. in includePath/browsePath, so it seemed reasonable to expect the syntax to work for specifying clang-format/clang-tidy files as well.

Steps to reproduce:

  1. Create a multi-root workspace with at least two named folders, e.g.
"folders": [
		{
			"name": "vscode",
			"path": ".."
		},
		{
			"name": "common",
			"path": <some path>
		}
]
  1. Set "C_Cpp.clang_format_style" to e.g. file:${workspaceFolder:common}/.clang-format
  2. Attempt to format a file..
  3. Formatting will fail.
  4. Observe that path was not expanded in C/C++ extension output window.

Expected behavior:
Path would be expanded to the correct multi-root workspace folder so that formatting completes successfully.

Configuration and Logs

vscode.code-workspace:
{
	"folders": [
		{
			"name": "vscode",
			"path": ".."
		},
		{
			"name": "services",
			"path": "../../../../../services"
		},
		{
			"name": "common",
			"path": "../../../../../common/scripts"
		}
	],
	"settings": {
		"terminal.integrated.env.windows": {
			"Path": "${config:OCD_path};${config:ARM_GCC_path}/bin;${config:xPack_GCC_path}/bin;${config:Make_path};${env:PATH}",
			"MAXIM_PATH": "${config:MAXIM_PATH}"
		},
		"terminal.integrated.defaultProfile.windows": "Command Prompt",

		"target":"MAX32670",
		"project_name":"${workspaceFolderBasename}",
		"program_file":"${config:project_name}.elf",
		"symbol_file":"${config:program_file}",

		"v_Arm_GCC":"10.3",
		"v_xPack_GCC":"10.2.0-1.2",

		"OCD_path":"${config:MAXIM_PATH}/Tools/OpenOCD",
		"ARM_GCC_path":"${config:MAXIM_PATH}/Tools/GNUTools/${config:v_Arm_GCC}",
		"xPack_GCC_path":"${config:MAXIM_PATH}/Tools/xPack/riscv-none-embed-gcc/${config:v_xPack_GCC}",
		"Make_path":"${config:MAXIM_PATH}/Tools/MSYS2/usr/bin",

		"C_Cpp.default.intelliSenseMode": "gcc-arm",
		"C_Cpp.default.compilerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gcc.exe",
		"C_Cpp.default.includePath": [
			"${workspaceFolder:vscode}",
			"${workspaceFolder:vscode}/**",
			"${workspaceFolder:services}/comm/include",
			"${config:MAXIM_PATH}/Libraries/CMSIS/Device/Maxim/${config:target}/Include",
			"${config:MAXIM_PATH}/Libraries/CMSIS/Include",
			"${config:ARM_GCC_path}/arm-none-eabi/include",
			"${config:ARM_GCC_path}/lib/gcc/arm-none-eabi/${config:v_Arm_GCC}/include",
			"${config:MAXIM_PATH}/Libraries/PeriphDrivers/Include/${config:target}",
			"${config:MAXIM_PATH}/Libraries/MiscDrivers/LED",
			"${config:MAXIM_PATH}/Libraries/MiscDrivers/PushButton"
		],
		"C_Cpp.default.browse.path": [
			"${workspaceFolder:vscode}",
			"${workspaceFolder:services}/comm/source",
			"${config:MAXIM_PATH}/Libraries/PeriphDrivers/Source",
			"${config:MAXIM_PATH}/Libraries/MiscDrivers/LED",
			"${config:MAXIM_PATH}/Libraries/MiscDrivers/PushButton",
			"${config:MAXIM_PATH}/Libraries/MiscDrivers"
		],
		"C_Cpp.default.defines": [
			"${config:target}"
		],
		"C_Cpp.autoAddFileAssociations": false,
		"C_Cpp.clang_format_style": "file:${workspaceFolder:common}/.clang-format",
		"C_Cpp.codeAnalysis.clangTidy.path": "file:${workspaceFolder:common}/.clang-tidy"
	}
}

Other Extensions

No response

Additional context

No response

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Apr 10, 2023

@jlj-ee Setting "C_Cpp.codeAnalysis.clangTidy.path": "file:${workspaceFolder:common}/.clang-tidy" is not valid. See https://releases.llvm.org/16.0.0/tools/clang/tools/extra/docs/clang-tidy/ . You'd need to use something like "C_Cpp.codeAnalysis.clangTidy.args": [ "--config-file=${workspaceFolder:common}/.clang-tidy" ].

@jlj-ee
Copy link
Author

jlj-ee commented Apr 10, 2023

@sean-mcmanus Thanks for the info!
Yes, I see I was mixing up that property, since C_Cpp.codeAnalysis.clangTidy.path is just the path to the binary.
But there was a path resolution bug for C_Cpp.clang_format_style?

@sean-mcmanus
Copy link
Collaborator

Yeah, the clang_format_style will be fixed for 1.15.2 (pre-release).

@sean-mcmanus
Copy link
Collaborator

@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Code Formatting Feature: Multi-root fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

3 participants