terminal: Inverse cursor color logic is (sometimes) broken

Environment

Windows build number:
Microsoft Windows [Version 10.0.18362.449]

Windows Terminal version (if applicable):
No.

Any other software?
No.

Steps to reproduce

  1. Open cmd.exe.
  2. Go to window properties, “Colors” page.
  3. Set “Screen Background” value to exactly 128 128 128.

Expected behavior

Cursor is visible no matter what background color is.

Actual behavior

Now you see it, now you don’t.

Current “inverse” logic is too straightforward - it literally takes the inverse of the background, and for 128 128 128 the inverse is… 127 127 127, which is basically the same thing. Oops.

Note: Legacy console handles this corner case properly, as well as all Windows versions prior to 10.

Also, legacy console inversion algorithm is not exactly “inverse” - the colors are slightly different (and subjectively more pleasant). Is it possible to get this classic inversion in the modern console please?

This issue affects a text editor app that uses console color 8 (128 128 128 in classic color scheme) to highlight various parts of text (e.g. current line). Sudden cursor disappearing is confusing and annoying.

Example:

image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

If you’d like to submit a PR for this - go for it!