ITADN

[Bug] Problems panel fails to open file because diagnostic resource contains appended line number

#4954OpenR34lt1m3 创建于 2026-05-27
bugmore info needed
R
R34lt1m3commented
### Brief Issue Summary Repro steps 1. Open a C++/CMake workspace which uses just a `CMakePresets.json` for a modern workflow **WITHOUT** `launch.json`/`tasks.json`. Example presets use per-configuration binaryDir values: - "binaryDir": "${sourceDir}/build-ninja-debug" - "binaryDir": "${sourceDir}/build-ninja-release" 2. Select an active preset in the CMake Tools extension and run Configure 3. Introduce a compile error in a source file (e.g. `src/TestFile.cpp`) 4. Build using the CMake Tools **Build** button (bottom-left) Observed - In the `OUTPUT` panel (set to show `CMake/Build`) the compile error is logged at `/home/myusername/myworkspaceroot/subproject/src/TestFile.cpp`. Clicking the URI path opens the file correctly - In the `PROBLEMS` panel clicking the problem fails with: `The editor could not be opened because the file was not found.` - Right‑click → **Copy** on the Problems entry yields JSON like:```[{ "resource": "/home/myusername/myworkspaceroot/subproject/src/TestFile.cpp:232", "owner": "cmake-build-diags", "severity": 8, "message": "required from here", "source": "cmake GNULD", "startLineNumber": 90, "startColumn": 1, "endLineNumber": 90, "endColumn": 1000, "origin": "extHost1" }]``` Note: the `resource` field contains the trailing `:232` Expected - The extension should publish diagnostics with a proper file URI (no trailing `:line`) and set the diagnostic range (startLineNumber/startColumn) appropriately so Problems opens the file at the correct location - If a problem matcher is required, document how to make the CMake Tools Build button publish correct diagnostics when using only CMakePresets.json (no tasks.json) ### CMake Tools Diagnostics ```shell { "os": "linux", "vscodeVersion": "1.121.0", "cmtVersion": "1.23.52", "configurations": [ { "folder": "/home/myusername/myworkspaceroot", "cmakeVersion": "3.28.3", "configured": true, "generator": "Ninja", "usesPresets": true, "compilers": { "C": "/usr/bin/cc", "CXX": "/usr/bin/c++" } } ], "cpptoolsIntegration": { "isReady": true, "hasCodeModel": true, "activeBuildType": "Debug", "buildTypesSeen": [ "Debug" ], "requests": [ "file:///home/myusername/myworkspaceroot/subproject/src/TestFile.cpp" ], "responses": [ { "uri": "file:///home/myusername/myworkspaceroot/subproject/src/TestFile.cpp", "configuration": { "includePath": [ "/home/myusername/myworkspaceroot/subproject/src", "/home/myusername/myworkspaceroot/subproject/include", "/home/myusername/myworkspaceroot/external", "/home/myusername/myworkspaceroot/build-debug-ninja/_deps/glm-src", "/home/myusername/myworkspaceroot/build-debug-ninja/_deps/spdlog-src/include" ], "defines": [ "SPDLOG_COMPILED_LIB" ], "compilerPath": "/usr/bin/c++", "compilerArgs": [], "compilerFragments": [ " -std=c++20 -Wall -Wextra -Wno-missing-field-initializers -Wimplicit-fallthrough=0 -fno-strict-aliasing -m64 -fvisibility=hidden -g" ] } } ], "partialMatches": [], "targetCount": 4, "executablesCount": 1, "librariesCount": 3, "targets": [ { "name": "spdlog", "type": "STATIC_LIBRARY" }, { "name": "glm", "type": "STATIC_LIBRARY" }, { "name": "subproject", "type": "STATIC_LIBRARY" }, { "name": "subproject2", "type": "EXECUTABLE" } ] }, "settings": [ { "communicationMode": "automatic", "useCMakePresets": "auto", "configureOnOpen": true } ] } ``` ### Debug Log ```shell [build] /home/myusername/myworkspaceroot/subproject/src/TestFile.cpp:232:90: required from here ``` ### Additional Information Environment - VS Code: Version: 1.121.0; Linux x64 6.8.0-117-generic snap - CMake Tools: 1.23.52 - CMake: 3.28.3 - OS: Ubuntu 24.04.4 LTS
1 条评论