Fix long compilation command truncation in Compile Active File#4702
Open
Fix long compilation command truncation in Compile Active File#4702
Conversation
When running "CMake: Compile Active File", commands longer than ~4096 characters were truncated by the terminal's input buffer. For long commands, write the command to a temporary script file and execute that instead. Fixes #3575 Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix long compilation command truncation issue
Fix long compilation command truncation in Compile Active File
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change addresses item #3575
This changes visible behavior
The following changes are proposed:
.shon Unix,.cmdon Windows) and execute that instead of passing it directly viaterminal.sendText(), which silently truncates at ~4096 characterssendText()directly (no behavior change)The purpose of this change
terminal.sendText()has a ~4096 character input buffer limit imposed by terminal emulators. Complex C/C++ projects with many include paths can easily exceed this, causing the compilation command to be truncated — typically losing the source file argument at the end, which makes gcc fail.The fix uses the same temp-script pattern already established in the codebase (
visualStudio.ts,kit.ts).Other Notes/Information
Files changed:
src/drivers/cmakeDriver.ts— AddedcreateCompileScript()helper and length check inrunCompileCommand()CHANGELOG.md— Added bug fix entry under v1.23Verification: CodeQL scan clean. Manual verification requires a project with a compilation database entry >4096 chars (e.g., thousands of
-Iflags).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
0psvsblobprodwus2145.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED --loglevel warn(dns block)2wrvsblobprodwus2180.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)40vvsblobprodwus2135.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --prefer-offline(dns block)5bdvsblobprodwus2128.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED --loglevel warn(dns block)7t8vsblobprodwus2168.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT(dns block)b15vsblobprodwus2164.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)b53vsblobprodwus2154.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)d94vsblobprodwus2119.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)ezcvsblobprodwus2170.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --prefer-offline(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT(dns block)k4pvsblobprodwus2140.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT(dns block)lusvsblobprodwus2166.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)n6wvsblobprodwus2123.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)p2tvsblobprodwus2189.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)pkwvsblobprodwus2126.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)v41vsblobprodwus2175.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install(dns block)vm9vsblobprodwus2190.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT(dns block)wztvsblobprodwus2155.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT(dns block)z2bvsblobprodwus2185.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)zt8vsblobprodwus2176.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)zugvsblobprodwus2169.vsblob.vsassets.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>Long compilation command truncated </issue_title>
<issue_description>### Brief Issue Summary
I have a C project with compilation database.
The project is very complex and has files with thousands of lines of code.
When running CMake: Compile Active File, the compilation command is spit into the newly created terminal, and below it a shell prompt with the same compilation command but truncated to 4096 (or 4095) characters.
The command fails because it is truncated and gcc cannot find which file to compile (which is.the last argument)
Running on vs code remote with ssh to ubuntu 20.04.
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response</issue_description>
<agent_instructions>You are Copilot coding agent acting as a senior maintainer/contributor for the VS Code extension repository microsoft/vscode-cmake-tools.
You are deeply familiar with CMake, CMake Presets, CTest, kit/toolchain selection, VS Code extension APIs, and the architecture of this repo (TypeScript-heavy).
Your job is to resolve the GitHub issue provided below safely and in a maintainable way, matching existing patterns and UX.
SOURCE OF TRUTH
Long compilation command truncated #3575 - Bug Long compilation command truncated #3575
NON-NEGOTIABLE PROCESS
Targeted scenario verification (must be addressed):
QUALITY BAR / GOTCHAS TO...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.