microsoft / microsoft/terminal

VT margins are meant to be tracked separately for each page

Open
#19,625 0 comments 0 reactions 0 assignees View on GitHub
Area-VT Help Wanted Issue-Bug Priority-2 Product-Conhost Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.24.2812.0

### Windows build number

10.0.19045.5371

### Other Software

_No response_

### Steps to reproduce

I first noticed this while trying out the Kermit [demo script](https://github.com/davidrg/ckwin/blob/2fe4f1c5b45971508e7601987cff7e17416f1eef/kermit/samples/demo.sh), but this is a simpler test case:
```
printf "\e#8\e[2 P\e[9;15r\e[1 P\e[999B\n\n\n\n\n\n\n"
```

That string has the following parts:
1. Fill the screen with a `DECALN` sequence.
2. Switch to page 2.
3. Sets the top/bottom margins to 9;15.
4. Switch back to page 1.
5. Move the cursor down as far as it can go.
6. Output a bunch of linefeeds to trigger a scroll.

### Expected Behavior

The margins set on page 2 should have no effect on page 1, so the scrolling should occur at the very bottom of the page. The top part of the screen should be filled with `E`s from the `DECALN`, while the bottom lines should be blank where it has scrolled up.

### Actual Behavior

We track the margins globally, so the margins set on page 2 apply to _both_ pages, and thus the scrolling only occur within the 9..15 margin area. The top and bottom parts of the screen are filled with `E`s, and the middle section is blank.

It's not obvious from the documentation that margins are supposed to be tracked per-page, but the [description of `DECSTBM`](https://vt100.net/docs/vt510-rm/DECSTBM.html) in the programmer's reference does hint at it with the wording "this control function sets the top and bottom margins **for the current page**" (emphasis mine). Interestingly they don't describe `DECSLRM` in the same way, but the rule applies to both. This has been confirmed with tests on the actual hardware.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied escape-sequence test and compare scrolling after setting margins on page 2 and returning to page 1. Trace the handling of DECSTBM and DECSLRM, then verify that each page retains its own margins and that the reproduction scrolls at the expected page boundaries.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.