microsoft / microsoft/terminal
Extra newline when copying line with wide glyph on the edge
- 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.


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
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