-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COOKED_READ_DATA: Fix scrolling under ConPTY (#15930)
This commit fixes 3 bugs: * `COOKED_READ_DATA` failed to initialize its `_distanceCursor` and `_distanceEnd` members. I took this as an opportunity to make them `ptrdiff_t`, to reduce the likelihood of overflows in the future. * `COOKED_READ_DATA::_writeChars` added `scrollY` to the written distance, even though `WriteCharsLegacy` writes a negative value into that out parameter. This was fixed by changing `WriteCharsLegacy` to write positive values and by adding a debug assertion. * `StreamScrollRegion` calls `IncrementCircularBuffer` which causes a synchronous (!) ConPTY flush to the output pipe (side note: this is the primary reason why newlines are so slow in ConPTY). Since cooked reads are supposed to behave like a pager and not write into the scrollback, we temporarily mark the buffer as inactive which prevents `TextBuffer` from snitching about it to VtEngine. Even after this change, there's still some weird behavior left: * You cannot move your cursor back beyond (0,0), because this isn't a real pager-like implementation. That might be a neat future extension. * Writing a lot of text and pressing Ctrl+C doesn't properly place the cursor and scroll the buffer, unless the cursor is at the end. That might also be worth investigating in the future (minor issue). * When the viewport is full, backspacing more than 1 line of text (using Ctrl+Backspace) doesn't erase all of the affected lines, because `COOKED_READ_DATA::_erase` uses the same `WriteCharsLegacy` function to write whitespace to erase that text. It's only gone after typing one more character. I've written the code to mostly fix this, but decided against it as I considered the problem to be too niche to warrant extra code. Closes #15899 ## Validation Steps Performed * Generate some text to paste in PowerShell: ```pwsh "" + (0..512 | % { "word" + $_.ToString().PadLeft(4, "0") }) ``` * Launch cmd.exe and paste that text * No flickering ✅ * No writing into the scrollback ✅ * No weird behavior when backspacing ✅
- Loading branch information
Showing
6 changed files
with
57 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters