microsoft / microsoft/terminal

Preview: Inconsistent Behavior When Writing to Stdout While Reading From Stdin

Open
#18,265 11 comments 0 reactions 0 assignees View on GitHub
Area-CookedRead Issue-Bug Needs-Tag-Fix Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.22.3232.0

### Windows build number

10.0.19045.5131

### Other Software

WSL seems to work fine, but other hosted terminals have this issue. To be clear, this only happens with the preview version of WT. The stable version works fine.

### Steps to reproduce

Create any program that begins reading from stdin and then after reading has begun, write to stdout. Here is an example program in golang:

```go
package main

import (
"bufio"
"fmt"
"os"
"os/signal"
"syscall"
"time"
)

func DoScan() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanRunes)

for scanner.Scan() {
fmt.Print(scanner.Text())
}
}

func main() {

go DoScan()
time.Sleep(1)

fmt.Print("Here is a prompt! >")

sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

<-sigs
}
```

### Expected Behavior

I expected that my typed keys would appear after the caret of the prompt output. That's what it does in the stable version of WT and that's what it does in WSL even in the preview version.

### Actual Behavior

My typed keys appear at the beginning of the line, overwriting the prompt.

Contributor guide

Open the contributing guide

Research direction

Start by running the Go reproducer in the Windows Terminal preview, then compare its stdin and stdout behavior with the stable version and WSL. Investigate the terminal's input and output handling; done means typed keys appear after the prompt caret instead of overwriting the prompt.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.