microsoft / microsoft/terminal

ResizeWithReflow doesn't clamp _virtualBottom if the cursor is above the viewport

Open
#17,023 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Windows Terminal version

1a6ba43

Windows build number

No response

Other Software

No response

Steps to reproduce

TBA: Exact steps unclear, but it was found by @zadjii-msft in #16937 as part of reflow tests.
However, repro steps aren't quite necessary as the flaw can be clearly seen here:
https://github.com/microsoft/terminal/blob/1a6ba43dd220d4a318627006bf2a6c8b9a70c7bc/src/host/screenInfo.cpp#L1404-L1407

There's no min(). (Alternatively, you can just patch Reflow() to put the cursor at 0,0 after a reflow.)

Terminal::UserResize doesn't use its newCursorPos either.

Expected Behavior

No response

Actual Behavior

The viewport should always contain the cursor, even if the cursor is above the viewport.

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 in src/host/screenInfo.cpp at the linked lines around Reflow(), and inspect how _virtualBottom and the cursor position are handled when the cursor is above the viewport. Also check Terminal::UserResize and its unused newCursorPos. Done means reflow and resize keep the viewport containing the cursor, including when the cursor starts above it.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.