Previous stdout buffer not visible #7390

Closed
opened 2026-01-31 01:02:43 +00:00 by claunia · 8 comments
Owner

Originally created by @ospinakamilo on GitHub (Apr 13, 2020).

Environment

Windows build number:  Win32NT   10.0.18363.0 Microsoft Windows NT 10.0.18363.0
Windows Terminal version (if applicable): Version: 0.10.781.0

Any other software?
Python 3.8.1

Steps to reproduce

  1. Have python>=3.6 installed.
  2. Add Python Scripts folder to the system path
  3. install the following pip dependency: pip install caos
  4. execute the help command in the terminal: caos --help

Expected behavior

Just like in CMD or Powershell I expected to be able to scroll up to the first lines of the printed help message

Actual behavior

Only the last lines of the printed help message are visible while using the terminal app, it works correctly on the cmd or PowerShell

Originally created by @ospinakamilo on GitHub (Apr 13, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Win32NT 10.0.18363.0 Microsoft Windows NT 10.0.18363.0 Windows Terminal version (if applicable): Version: 0.10.781.0 Any other software? Python 3.8.1 ``` # Steps to reproduce 1. Have python>=3.6 installed. 2. Add Python Scripts folder to the system path 2. install the following pip dependency: pip install caos 3. execute the help command in the terminal: caos --help # Expected behavior Just like in CMD or Powershell I expected to be able to scroll up to the first lines of the printed help message # Actual behavior Only the last lines of the printed help message are visible while using the terminal app, it works correctly on the cmd or PowerShell
claunia added the Needs-TriageArea-VTNeeds-Tag-FixProduct-Conpty labels 2026-01-31 01:02:43 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Apr 13, 2020):

For future me: the python scripts directory was %localappdata%\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts for me.

This is weirdly only reproing for me with the caos.exe in that folder. virtualenv.exe --help in the same folder can display it's output in the scrollback (history) just fine. I'd wonder if caos is using some peculiar API to scroll the console viewport on Windows.

This also repros if you run cmd.exe in inception in conhost (wsl.exe cmd.exe), so it's definitely something weird about their interaction with conpty.

@zadjii-msft commented on GitHub (Apr 13, 2020): For future me: the python scripts directory was `%localappdata%\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts` for me. This is weirdly only reproing for me with the `caos.exe` in that folder. `virtualenv.exe --help` in the same folder can display it's output in the scrollback (history) just fine. I'd wonder if `caos` is using some peculiar API to scroll the console viewport on Windows. This also repros if you run `cmd.exe` in inception in conhost (wsl.exe cmd.exe), so it's definitely something weird about their interaction with conpty.
Author
Owner

@ospinakamilo commented on GitHub (Apr 13, 2020):

Indeed it seems to be reproducible running cmd.exe within wsl.exe:
This is the content of caos.exe

# -*- coding: utf-8 -*-
import re
import sys
from caos._cli import cli_entry_point
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(cli_entry_point())

And for the help command, is just doing a print(). Can the problem be related to the fact that some DLLs are being injected to enable colors in the terminal(ANSICON)? (http://adoxa.altervista.org/ansicon)

@ospinakamilo commented on GitHub (Apr 13, 2020): Indeed it seems to be reproducible running cmd.exe within wsl.exe: This is the content of caos.exe ```python # -*- coding: utf-8 -*- import re import sys from caos._cli import cli_entry_point if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(cli_entry_point()) ``` And for the help command, is just doing a print(). Can the problem be related to the fact that some DLLs are being injected to enable colors in the terminal(ANSICON)? (http://adoxa.altervista.org/ansicon)
Author
Owner

@DHowett-MSFT commented on GitHub (Apr 13, 2020):

The author of ansicon wrote it in 2019? Four years after we shipped general VT support for all consoles with Windows 10? Jeez.

@DHowett-MSFT commented on GitHub (Apr 13, 2020): The author of ansicon wrote it in 2019? Four years after we shipped general VT support for all consoles with Windows 10? Jeez.
Author
Owner

@ospinakamilo commented on GitHub (Apr 13, 2020):

It seems indeed the problem is the injection of the ANSICON DLLs. Since which version of windows 10 can I rely on the ANSI sequence being available? so that I can inject the ANSICON DLLs only for older windows versions.

@ospinakamilo commented on GitHub (Apr 13, 2020): It seems indeed the problem is the injection of the ANSICON DLLs. Since which version of windows 10 can I rely on the ANSI sequence being available? so that I can inject the ANSICON DLLs only for older windows versions.
Author
Owner

@DHowett-MSFT commented on GitHub (Apr 13, 2020):

You can rely on most sequences starting in Windows 10 10.0.10240.0, and the subsequent releases only expanded support. I’m going to go out on a limb and guess that ansicon doesn’t quite hit the compatibility level we were going for in 10240, so this shouldn’t be a regression in functionality for you.

@DHowett-MSFT commented on GitHub (Apr 13, 2020): You can rely on most sequences starting in Windows 10 10.0.10240.0, and the subsequent releases only expanded support. I’m going to go out on a limb and guess that ansicon doesn’t quite hit the compatibility level we were going for in 10240, so this shouldn’t be a regression in functionality for you.
Author
Owner

@ospinakamilo commented on GitHub (Apr 13, 2020):

Thanks, I will add a release check to avoid injecting the ANSICON DLLs when not required and I think we can consider this issue as closed.

@ospinakamilo commented on GitHub (Apr 13, 2020): Thanks, I will add a release check to avoid injecting the ANSICON DLLs when not required and I think we can consider this issue as closed.
Author
Owner

@eryksun commented on GitHub (Apr 13, 2020):

Since which version of windows 10 can I rely on the ANSI sequence being available?

Try to set ENABLE_VIRTUAL_TERMINAL_PROCESSING (4) in the screen buffer (stdout) via GetConsoleMode and SetConsoleMode, and fall back on something else if it fails as an invalid parameter (87). Python itself does not enable this console mode.

@eryksun commented on GitHub (Apr 13, 2020): > Since which version of windows 10 can I rely on the ANSI sequence being available? Try to set `ENABLE_VIRTUAL_TERMINAL_PROCESSING` (4) in the screen buffer (stdout) via `GetConsoleMode` and `SetConsoleMode`, and fall back on something else if it fails as an invalid parameter (87). Python itself does not enable this console mode.
Author
Owner

@ospinakamilo commented on GitHub (Apr 13, 2020):

Thanks, I'll do that. I leave here a reference on how you solved the problem:
https://bugs.python.org/msg291732

@ospinakamilo commented on GitHub (Apr 13, 2020): Thanks, I'll do that. I leave here a reference on how you solved the problem: [https://bugs.python.org/msg291732](https://bugs.python.org/msg291732)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7390