Skip to content

Terminal: Selection range doesn't extend correctly across terminal reflow boundaries after resize #310422

@Nedunchezhiyan-M

Description

@Nedunchezhiyan-M

Bug Report

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: Latest
  • OS Version: Linux / macOS

Steps to Reproduce

  1. Open a terminal
  2. Run a command that produces a long output line (longer than terminal width):
    echo "This is a very long line that will wrap in the terminal when the terminal width is narrow enough to cause wrapping behavior"
  3. Observe the line wrapping in the terminal
  4. Click at the beginning of the line and drag to select it entirely (across the wrap point)
  5. Now resize the terminal panel (make it wider or narrower)
  6. Try to select the same content again

Expected Behavior

After resize, terminal content reflows (rewraps at the new width). Text selection should work correctly across the new reflow boundaries — selecting from one visual line to another should select the logically connected text.

Actual Behavior

After resize and reflow, text selection behaves incorrectly:

  • Selecting across a reflow boundary sometimes selects only up to the boundary
  • Copy (Ctrl+C) of a selection that spans a reflow boundary may include an extra newline
  • Or the selection visually highlights correctly but copies incorrect text

Impact

This affects workflows where:

  1. Terminal window is frequently resized (split panel, drag divider)
  2. Long command outputs (JSON, stack traces) wrap and then reflow
  3. Text is copied from terminal to paste elsewhere

Notes

Terminal reflow is a known complex area. The selection tracking needs to map visual positions to logical buffer positions after reflow. The xterm.js library handles reflow, and VS Code's selection coordinate translation may not account for all reflow scenarios.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions