Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vanishing cursor and prints to wrong lines #7479

Open
Tracked by #5800
Ennea opened this issue Aug 31, 2020 · 5 comments
Open
Tracked by #5800

Vanishing cursor and prints to wrong lines #7479

Ennea opened this issue Aug 31, 2020 · 5 comments
Labels
Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Milestone

Comments

@Ennea
Copy link

Ennea commented Aug 31, 2020

Environment

Windows build number: Microsoft Windows [Version 10.0.19041.450]
Windows Terminal version: 1.2.2381.0

Steps to reproduce

Run this sample Python script:

import curses

def main(window):
        _, width = window.getmaxyx()
        window.getkey()
        window.addstr(0, 0, '-' * width)
        window.getkey()
        window.addstr(2, 0, '-' * (width - 1))
        window.getkey()
        window.addstr(4, 0, '-' * width)
        window.move(5, 0)
        window.getkey()
        window.addstr(6, 0, '-' * width)
        window.move(7, 1)
        window.getkey()

curses.wrapper(main)

Expected behavior

The script prints a bunch of lines made up of dashes. The first, third and fourth span the entire width of the terminal, the second is one character short. After each print of a line, the cursor should be visible. For the first and second lines, it should be right after the line (wrapped to the second row in case of the first one). For the third and fourth, the cursor is manually moved to the next row.

cmd

Actual behavior

Using Windows Terminal, the cursor does not show after printing the first line. It does after printing the second. It again does not after printing the third, and does show again after printing the fourth and last. Additionally, the lines are printed to row 0, 1, 4 and 5, instead of the expected 0, 2, 4 and 6.

Windows Terminal

Additional info

This one is weird. Originally I only wanted to file a bug for the vanishing cursor. When constructing some sample script, I also ran into the issue where successive prints also ended up on the completely wrong lines. So the cursor seems to vanish when printing just as many characters to fill the terminal's width, so that the cursor has to wrap to the next line. Printing one less or one more does not make the cursor vanish. Manually moving it to the first column after printing such a full line will also not fix this, but moving it to the second column will show it again. And for some reason, even though I provide both y and x (in that order) to addstr in my sample script, Windows Terminal will not print these strings to the correct rows/lines.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Aug 31, 2020
@Ennea
Copy link
Author

Ennea commented Aug 31, 2020

Also tested this in the latest preview (1.3.2382.0), bug still exists there.

@jdebp
Copy link

jdebp commented Sep 15, 2020

If it helps diagnosis any, PDCurses may or may not ignore the actual console screen buffer size (depending from what is in the process's environment), may or may not explicitly move the cursor around when outputting lines in doupdate() (depending from what is in the process's environment and one's colour choices), and doesn't reset the old console mode after changing it (only resetting it at endwin()),

@zadjii-msft
Copy link
Member

@Ennea are you running the above python script with python.exe, or with a python from a WSL distro?

@zadjii-msft zadjii-msft added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-Terminal The new Windows Terminal. labels Sep 29, 2020
@Ennea
Copy link
Author

Ennea commented Sep 29, 2020

@zadjii-msft Both. Whether I use Windows Terminal to run CMD or my WSL shell, the bug happens in both cases. Looks like I was mistaken, this only happens inside WSL. I use WSL 1, if that matters at all. I also tried Python 2 (I normally use 3 for everything nowadays), and the same thing happens.

Okay, second edit, sorry about this... I went back to it and can also successfully reproduce it in CMD, running Python 3.8:

import curses

def main(window):
    _, width = window.getmaxyx()
    curses.curs_set(0)
    window.getkey()
    curses.curs_set(1)
    window.addstr(0, 0, '-' * width)
    window.getkey()
    curses.curs_set(0)
    window.getkey()
    curses.curs_set(1)
    window.addstr(2, 0, '-' * (width - 1))
    window.getkey()

curses.wrapper(main)

What this sample script does, compared to the first one, is also hide the cursor first using curs_set, and then show it immediately before printing the lines. Besides this change, all the symptoms are the same. The lines that the strings are being printed to is off, and the cursor is not shown when it'd end up on the first column of the next line after printing.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Sep 29, 2020
@zadjii-msft
Copy link
Member

oh man I'm having a faint memory of an issue where moving the cursor while the cursor was hidden at the end of a previous frame would cause us to fail to update it's location before printing the next conpty frame. I can't remember anything more about it off the top of my head though.

Fortunately, we've got a great minimal repro here, so we should be able to turn that into a unittest as well. Thanks!

@zadjii-msft zadjii-msft added Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) Priority-2 A description (P2) and removed Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 1, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Oct 1, 2020
@zadjii-msft zadjii-msft added this to the Terminal v2.0 milestone Oct 1, 2020
@zadjii-msft zadjii-msft modified the milestones: Terminal v2.0, 22H2 Jan 4, 2022
@zadjii-msft zadjii-msft modified the milestones: 22H2, Backlog Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

3 participants