Skip to content

Input on line at end of scrolling region (set with DECSTBM) causes cursor to move down outside the scroll region #19016

Open
@DavidSpickett

Description

@DavidSpickett

Windows Terminal version

1.21.11141.0

Windows build number

10.0.22631.5335

Other Software

This is a standalone program that replicates what LLDB is seeing (llvm/llvm-project#134846) when enabling LLDB's status line feature. This statusline feature is only present in development (main branch) builds of llvm 21 and is currently disabled on Windows due to this bug.

I'm attaching a test program that does the same thing without referring to any lldb code. I can provide a patch to re-enable it in LLDB if anyone wants it, but probably easier to ask me to do it if you want to know something about LLDB specifically.

console_test.zip

There is C program that creates a basic REPL with a persistent status bar. You can type "hello", nothing, or random letters then press enter to get it to respond with some output.

The makefile uses cl.exe to build, I can get the versions for that if it would be useful to you. I should note that this is Windows on Arm, I have not been able to try a Windows x64 machine.

Steps to reproduce

Open a Visual Studio developer command prompt and build the application in there.

cl.exe test.c

(makefile is for Linux/gcc)

Then run it in a Windows Terminal tab. Normal command prompt or PowerShell, both show this problem.

.\test.exe

You should see this at the top of the terminal:

Simple REPL. Type commands below:
> <-- your cursor is here, one char beyond the '>'

And at the bottom of the screen:

Status (draw 1): Type 'hello' to greet. Ctrl+C or "q" to exit.

(though the ctrl-c part isn't implemented for Windows, it's not relevant to this problem)

draw 1 means it's the first time it's drawn the bar, enter redraw to redraw it, if you want to check for overlapping text issues. In theory this program never needs to redraw the status bar because it's outside of the scroll area.

Enter some input and press enter:

Simple REPL. Type commands below:
> hello
hello!
> <-- cursor is here again

It acts as any other REPL, going down the screen towards the status bar as more output is generated.

Expected Behavior

That you can continue entering input and pressing enter, and the output will continue down the screen until the status bar. When you are right above the status bar, input is echoed on the last line of the scroll window and new output lines cause all the content to scroll up one row, so as not to overwrite the status bar.

This is what happens on Linux using Ubuntu's default terminal.

Empty command
> <-- your cursor is here
Status (draw 1): Type 'hello' to greet. Ctrl+C or "q" to exit.

Input echoes to the current line:

Empty command
> h<-- your cursor is here
Status (draw 1): Type 'hello' to greet. Ctrl+C or "q" to exit.

New output lines cause content to scroll up:

Empty command
> h
Unknown command: h
> <-- your cursor is here 
Status (draw 1): Type 'hello' to greet. Ctrl+C or "q" to exit.

Rather than overwrite the status line.

The terminal should act this way no matter how many times the user does this. It should keep scrolling the content up.

Actual Behavior

The problem is when we get down to just above the status bar. This is the first time you reach that position:

Empty command
> <-- your cursor is here
Status (draw 1): Type 'hello' to greet. Ctrl+C or "q" to exit.

Type something and press enter:

Empty command
> abc
Unknown command: abc
>
Status (draw 1): Type 'hello' to greet. Ctrl+C or "q" to exit.

So far, so good. Now try that again, here I typed "z":

Empty command
> abc
Unknown command: abc
>
Stztus (draw 1): Type 'hello' to greet. Ctrl+C or "q" to exit.
   ^
    \----- the cursor moved vertically down one row before printing the "z" I entered.

It has now started to write over the status bar.

Here it is in image form.

When we first reach the bottom of the scroll window:
Image

Then enter a command:
Image

That works, but the second time, it does not work:
Image

From here, the program is stuck in some sort of "one line mode" where it will only output and print on that last line. I guess because it knows it is outside the scroll window, so it can't scroll up into that.

It manages to work once, which I find suspicious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CookedReadThe cmd.exe COOKED_READ handlingIssue-BugIt either shouldn't be doing this or needs an investigation.Priority-3A description (P3)Product-ConhostFor issues in the Console codebaseProduct-TerminalThe new Windows Terminal.

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions