Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.19] Shell integration marks are totally in the wrong place #16034

Closed
zadjii-msft opened this issue Sep 26, 2023 · 7 comments · Fixed by #16105
Closed

[1.19] Shell integration marks are totally in the wrong place #16034

zadjii-msft opened this issue Sep 26, 2023 · 7 comments · Fixed by #16105
Assignees
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree.

Comments

@zadjii-msft
Copy link
Member

zadjii-msft commented Sep 26, 2023

This was on
Windows Terminal Canary
Version: 1.19.2643.0

shell-integration-crazy-wrong

Looks like the marks are like... off by one?

Possible culprits:

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Sep 26, 2023
@zadjii-msft
Copy link
Member Author

Looks like this is also busted in v1.19.2652.0

@zadjii-msft zadjii-msft added Product-Terminal The new Windows Terminal. Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 27, 2023
@zadjii-msft zadjii-msft self-assigned this Sep 27, 2023
@zadjii-msft zadjii-msft added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Sep 27, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 27, 2023
@zadjii-msft
Copy link
Member Author

oh no, scrolling is really badly messed up

image
image
image

@zadjii-msft
Copy link
Member Author

zadjii-msft commented Sep 28, 2023

Bisecting. Starting by looking for a good commit around

❔ ✅ ❌

@zadjii-msft
Copy link
Member Author

4ddfc3e is the first bad commit
commit 4ddfc3e

COOKED_READ_DATA: Fix scrolling under ConPTY (#15930)

@zadjii-msft
Copy link
Member Author

Okay this is 100% due to:

// ConPTY translates scrolling into newlines. We don't want that during cooked reads (= "cmd.exe prompts")
// because the entire prompt is supposed to fit into the VT viewport, with no scrollback. If we didn't do that,
// any prompt larger than the viewport will cause >1 lines to be added to scrollback, even if typing backspaces.
// You can test this by removing this branch, launch Windows Terminal, and fill the entire viewport with text in cmd.exe.
if (needsConPTYWorkaround)
{
buffer.SetAsActiveBuffer(false);
buffer.IncrementCircularBuffer(buffer.GetCurrentAttributes());
buffer.SetAsActiveBuffer(isActiveBuffer);
if (isActiveBuffer && renderer)
{
renderer->TriggerRedrawAll();
}
}

@lhecker how load bearing is that? I know that comment sounds super scary above it, but manually setting needsConPTYWorkaround to false definitely fixes the scrolling and marks issue.

@zadjii-msft zadjii-msft added this to the Terminal v1.20 milestone Sep 28, 2023
@zadjii-msft zadjii-msft added the Severity-Blocking We won't ship a release like this! No-siree. label Sep 28, 2023
@lhecker
Copy link
Member

lhecker commented Sep 28, 2023

I'll fix #16044 and this issue in a single PR.
For #16044 I'll make it so that appending text only reprints the minimum amount of text that's necessary and for this issue I'll revert the above code entirely.

After all that, I'll reopen #15899 and leave it unfixed for the foreseeable future, because as much of a significant bug it is, I feel like fixing it is too difficult for the impact it has. To properly fix it, it always either required us to sacrifice on our i18n or to implement a pager, both of which are a pain to do. We have other issues that are much easier to fix and are hit much more often, right?
And if we don't reprint the entire prompt when appending text, I don't think it'll be hit very often. After all, cmd.exe always reprinted the entire prompt when inserting in the middle...

@zadjii-msft
Copy link
Member Author

Totally cool with that. Tossing this one over to you then ☺️

@zadjii-msft zadjii-msft assigned lhecker and unassigned zadjii-msft Sep 28, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Oct 5, 2023
DHowett pushed a commit that referenced this issue Oct 24, 2023
The initial cooked read (= conhost readline) rewrite had two flaws:
* Using viewport scrolls under ConPTY to avoid emitting newlines
resulted in various bugs around marks, coloring, etc. It's still
somewhat unclear why this happened, but the next issue is related and
much worse.
* Rewriting the input line every time causes problems with accessibility
tools, as they'll re-announce unchanged parts again and again.

The solution to these is to simply stop writing the unchanged parts of
the prompt. To do this, code was added to measure the size of text
without actually inserting them into the buffer. Since this meant that
the "interactive" mode of `WriteCharsLegacy` would need to be duplicated
for the new code, I instead moved those parts into `COOKED_READ_DATA`.
That way we can now have the interactive transform of the prompt (=
Ctrl+C -> ^C) and the two text functions (measure text & actually write
text) are now agnostic to this transformation.

Closes #16034
Closes #16044

## Validation Steps Performed
* A vision impaired user checked it out and it seemed fine ✅
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Oct 24, 2023
DHowett pushed a commit that referenced this issue Oct 26, 2023
The initial cooked read (= conhost readline) rewrite had two flaws:
* Using viewport scrolls under ConPTY to avoid emitting newlines
resulted in various bugs around marks, coloring, etc. It's still
somewhat unclear why this happened, but the next issue is related and
much worse.
* Rewriting the input line every time causes problems with accessibility
tools, as they'll re-announce unchanged parts again and again.

The solution to these is to simply stop writing the unchanged parts of
the prompt. To do this, code was added to measure the size of text
without actually inserting them into the buffer. Since this meant that
the "interactive" mode of `WriteCharsLegacy` would need to be duplicated
for the new code, I instead moved those parts into `COOKED_READ_DATA`.
That way we can now have the interactive transform of the prompt (=
Ctrl+C -> ^C) and the two text functions (measure text & actually write
text) are now agnostic to this transformation.

Closes #16034
Closes #16044

## Validation Steps Performed
* A vision impaired user checked it out and it seemed fine ✅

(cherry picked from commit e1c69a9)
Service-Card-Id: 90891693
Service-Version: 1.19
js324 pushed a commit to js324/terminal that referenced this issue Dec 7, 2023
The initial cooked read (= conhost readline) rewrite had two flaws:
* Using viewport scrolls under ConPTY to avoid emitting newlines
resulted in various bugs around marks, coloring, etc. It's still
somewhat unclear why this happened, but the next issue is related and
much worse.
* Rewriting the input line every time causes problems with accessibility
tools, as they'll re-announce unchanged parts again and again.

The solution to these is to simply stop writing the unchanged parts of
the prompt. To do this, code was added to measure the size of text
without actually inserting them into the buffer. Since this meant that
the "interactive" mode of `WriteCharsLegacy` would need to be duplicated
for the new code, I instead moved those parts into `COOKED_READ_DATA`.
That way we can now have the interactive transform of the prompt (=
Ctrl+C -> ^C) and the two text functions (measure text & actually write
text) are now agnostic to this transformation.

Closes microsoft#16034
Closes microsoft#16044

## Validation Steps Performed
* A vision impaired user checked it out and it seemed fine ✅
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants