microsoft / microsoft/terminal

Cursor attributes cannot be set with ANSI VT Sequences before any user input

Open
#16,749 14 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-TerminalControl Area-VT Issue-Bug Priority-3 Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

Windows Terminal version

1.20.10303.0

Windows build number

10.0.22631.0

Other Software

N/A (the code in the repro steps should create the effect)

Steps to reproduce
  1. Compile something along the lines of the following C++ code:
#include <iostream>
int main() {
	std::cout << "\033[2 q";
	std::cin.get();
	std::cout << "\033[2 q";
	std::cin.ignore(99999999, '\n'); // you can use INT_MAX in place of the spammed 9s
        std::cin.get();

	return 0;
}

This code sets the new cursor attributes, waits for an ENTER key, sets the new cursor attributes again, and waits for an enter key again.

  1. Run it by clicking on the generated executable, NOT from the VS debug console (if using VS)
  2. The first time the program requests an ENTER key, there should be the default cursor attributes. Once the ENTER key is pressed, only then should the cursor attributes set.

https://github.com/microsoft/terminal/assets/66303587/93491fa7-daf8-4c87-aea6-e43df0ea6eaf

Expected Behavior

Cursor attributes should have been set on command before any user input.

Actual Behavior

Cursor attribute setting was ignored, until user inputted an ENTER character. Only then could any of the necessary cursor attribute VT sequences work (e.g "\033[2 q").

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the provided C++ program and running the executable from Windows Terminal rather than the Visual Studio debug console. Investigate why the first \033[2 q sequence is ignored until ENTER is pressed, and consider the issue resolved when cursor attributes apply before any user input and remain functional afterward.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.