microsoft / microsoft/terminal

Extra newline when copying line with wide glyph on the edge

Open
#11,739 6 comments 0 reactions 0 assignees View on GitHub
Area-Output Issue-Bug Priority-2 Product-Conpty
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version (or Windows build number)

10.0.19043.1348, 1.12.2931.0

### Other Software

Ubuntu 21.04 in WSL

### Steps to reproduce

1. Open tab with some WSL distro, shouldn't matter which.

2. Create python3 file with the following content:

```python
import os
import sys
cols = os.get_terminal_size().columns
sys.stdout.buffer.write(b'a'*(cols-1))
sys.stdout.buffer.write(b'\xea\xb0\x9c')
```

3. Run it:

```bash
python3 1.py
```

4. Copy output with the mouse and paste to some editor.

### Expected Behavior

There should be only single line of text.

### Actual Behavior

There're two lines of text, see screenshots.

![1](https://user-images.githubusercontent.com/533383/141378349-7ccab42d-d1e2-47c4-976e-f2be0ea33abc.png)
![2](https://user-images.githubusercontent.com/533383/141378343-bf8d1612-6b0a-4c4b-85dc-08a5ba018094.png)

The problem doesn't appear if that 3-byte symbol is not on the edge of the line. Also 2-byte symbols work fine too.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the Python script in the WSL terminal and copying the output with the mouse. Trace the Windows Terminal copy path for lines ending with a wide glyph, then verify that the copied result contains one line when the glyph is on the edge and that existing two-byte cases remain unaffected.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.