Skip to content

Copying wrapped GitHub Copilot CLI output can turn var c into varc #3666

@zuntan

Description

@zuntan

Describe the bug

Summary:
Copying wrapped output from GitHub Copilot CLI sometimes removes spaces from the clipboard text.

The issue is especially noticeable in long code output. For example, when a TypeScript fragment such as var c = ""; appears inside a long generated code block, and the visual line wrap occurs at the space between var and c, the copied clipboard text may become varc = "";.

Expected behavior:
Copied text should preserve the exact output, including spaces.

Example expected text:
var c = "";

Actual copied text:
varc = "";

Impact:
This changes the TypeScript code. var c = ""; is a variable declaration, while varc = ""; is an assignment to an identifier named varc. The copied code may fail to compile or behave differently from the generated code.

Additional observation:
I asked Copilot CLI to produce the same code in two ways:

  1. Write the code directly to a file.
  2. Print the same code to the terminal output.

The file output preserves spaces correctly.
The text copied from the terminal output sometimes loses spaces, especially around visual line-wrap positions.

This suggests that the generated code itself is correct, and the issue is likely in the terminal rendering/copy/clipboard path.

Reproduction steps:

  1. Start GitHub Copilot CLI.
  2. Ask it to output relatively long TypeScript code with long lines and spaces between tokens.
  3. Ensure that a fragment like var c = ""; is visually wrapped at the space between var and c.
  4. Also ask it to write the same code directly to a file.
  5. Copy the code from the Copilot CLI terminal output.
  6. Copy the code from the generated file.
  7. Paste both into plain text files.
  8. Compare the pasted text.

Example diff:

  • var c = "";
  • varc = "";

Environment:
GitHub Copilot CLI version:
OS:
Terminal:
Shell:
Terminal width:
tmux/screen:
Node.js version:
npm version:

Notes:
The issue appears more frequently with longer code output and visual word wrapping. In the observed case, the missing space was exactly the space between the TypeScript keyword var and the identifier c.

Affected version

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:input-keyboardKeyboard shortcuts, keybindings, copy/paste, clipboard, mouse, and text inputarea:terminal-renderingDisplay and rendering: flickering, scrolling, line wrapping, output formatting

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions