Commit Graph

4059 Commits

Author SHA1 Message Date
Adam Reynolds dd83ba62cf Fixed crash when cloud shell provider timed out or was closed waiting for login (#16364)
## Summary of the Pull Request
Cloud shell connection calls out to Azure to do a device code login.
When the polling interval is exceeded or the tab is closed, the method
doing the connection polling returns `nullptr`, and `AzureConnection`
immediately tries to `GetNamedString` from it, causing a crash. This
doesn't repro on Terminal Stable or Preview, suggesting it's pretty
recent related to the update of this azureconnection.

This is just a proposed fix, not sure if you want to do more extensive
changes to the affected class or not, so marking this as a draft.

## References and Relevant Issues
* N/A - encountered this while using the terminal myself

## PR Checklist/Validation
Tested out a local dev build:

- [x] Terminal doesn't crash when cloudshell polling interval exceeded
- [x] Terminal doesn't crash when cloudshell tab closed while polling
for Azure login

(cherry picked from commit 0c4751ba30)
Service-Card-Id: 91232784
Service-Version: 1.19
2023-12-04 14:25:10 -06:00
Leonard Hecker d4292d16cc Fix scrolling with SetConsoleWindowInfo (#16334)
81b7e54 caused a regression in `SetConsoleWindowInfo` and any other
function that used the `WriteToScreen` helper. This is because it
assumes that it can place the viewport anywhere randomly and it was
written at a time where `TriggerScroll` didn't exist yet (there was
no need for that (also not today, but that's being worked on)).

Caching the viewport meant that `WriteToScreen`'s call to
`TriggerRedraw` would pick up the viewport from the last rendered
frame, which would cause the intersection of both to be potentially
empty and nothing to be drawn on the screen.

This commit reverts 81b7e54 as I found that it has no or negligible
impact on performance at this point, likely due to the overall
vastly better performance of conhost nowadays.

Closes #15932

## Validation Steps Performed
* Scroll the viewport by entire pages worth of content using
  `SetConsoleWindowInfo` - see #15932
* The screen and scrollbars update immediately 

(cherry picked from commit 7a1b6f9d2a)
Service-Card-Id: 91152167
Service-Version: 1.19
2023-12-04 14:25:09 -06:00
Lonny Wong a4ec8ec591 Fix Control+Space not sent to program running in terminal (#16298)
Converts null byte to specific input event, so that it's properly
delivered to the program running in the terminal.

Closes #15939

(cherry picked from commit 8747a39a07)
Service-Card-Id: 91201444
Service-Version: 1.19
2023-12-04 14:25:08 -06:00
Leonard Hecker 3538a9f72b Fix input buffering for A APIs (#16313)
This fixes an issue where character-wise reading of an input like "abc"
would return "a" to the caller, store "b" as a partial translation
(= wrong) and return "c" for the caller to store it for the next call.

Closes #16223
Closes #16299

## Validation Steps Performed
* `ReadFile` with a buffer size of 1 returns inputs character by
  character without dropping any inputs 

---------

Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
(cherry picked from commit 63b3820a18)
Service-Card-Id: 91122022
Service-Version: 1.19
2023-12-04 14:24:20 -06:00
Leonard Hecker 5ed7dc2f63 ConPTY: Fix a shutdown deadlock with WSL (#16340)
Under normal circumstances this bug should be rare as far as I can
observe it on my system. However, it does occur randomly.

In short, WSL doesn't pass us anonymous pipes, but rather WSA sockets
and those signal their graceful shutdown first before being closed
later by returning a `lpNumberOfBytesRead` of 0 in the meantime.

Additionally, `VtIo` synchronously pumps the input pipe to get the
initial cursor position, but fails to check `_exitRequested`.
And so even with the pipe handling fixed, `VtIo` will also deadlock,
because it will never realize that `VtInputThread` is done reading.

## Validation Steps Performed
* Build commit 376737e with this change and replace conhost with it
  Coincidentally it contains a bug (of as of yet unknown origin)
  due to which the initial cursor position loop in `VtIo` never
  completes. Thanks to this, we can easily provoke this issue.
* Launch WSL in conhost and run an .exe inside it
* Close the conhost window
* Task manager shows that all conhost instances exit immediately

(cherry picked from commit adb04729bc)
Service-Card-Id: 91152102
Service-Version: 1.19
2023-12-04 14:24:18 -06:00
Leonard Hecker 0d353d8be5 Fix nearby fonts for DxEngine again (#16323)
The nearby font loading has to be outside of the try/catch of the
`_FindFontFace` call, because it'll throw for broken font files.
But in my previous PR I had overlooked that the font variant loop
modifies the only copy of the face name that we got and was in the
same try/catch. That's bad, because once we get to the nearby search
code, the face name will be invalid. This commit fixes the issue by
wrapping each individual `_FindFontFace` call in a try/catch block.

Closes #16322

## Validation Steps Performed
* Remove every single copy of Windows Terminal from your system
* Manually clean up Cascadia .ttf files because they aren't gone
* Destroy your registry by manually removing appx references (fun!)
* Put the 4 Cascadia .ttf files into the Dev app AppX directory
* Launch
* No warning 

(cherry picked from commit b780b44528)
Service-Card-Id: 91114951
Service-Version: 1.19
2023-12-04 14:24:17 -06:00
Dustin L. Howett abab8705fe Add a magic incantation to tell the Store we support Server (#16306)
I find it somewhat silly that (1) this isn't documented anywhere and (2)
installing the "desktop experience" packages for Server doesn't
automatically add support for the `Windows.Desktop` platform...

Oh well.

I'm going to roll this one out via Preview first, because if the store
blows up on it I would rather it not be during Stable roll-out.

(cherry picked from commit 86fb9b4478)
Service-Card-Id: 91098597
Service-Version: 1.19
2023-12-04 14:24:14 -06:00
Leonard Hecker 654b755161
Fix backspacing over control visualizers (#16400)
During `!measureOnly` the old code would increment `distance` twice.
Now it doesn't. :)

Closes #16356

## Validation Steps Performed
See updated test instructions in `doc/COOKED_READ_DATA.md`
2023-12-04 14:14:26 -06:00
Leonard Hecker be9fc200c7
Fix dwControlKeyState always including ENHANCED_KEY (#16335)
Since all VT parameters are treated to be at least 1 (and 1 if they're
absent or 0), `modifierParam > 0` was always true. This meant that
`ENHANCED_KEY` was always being set. It's unclear why `ENHANCED_KEY`
was used there, but it's likely not needed in general.

Closes #16266

## Validation Steps Performed
* Can't test this unless we fix the win32 input mode issue #16343 
2023-11-30 15:55:06 +01:00
Leonard Hecker 130c9fbd76
Remove unused Utf8ToWideCharParser (#16392)
I randomly came across this class, that I didn't even remember we had.
We don't use this class at the moment and won't need it any time soon.
Its current implementation is also fairly questionable. While
`til::u16state` isn't "perfect", it's vastly better than this.
2023-11-30 15:52:39 +01:00
Adam Reynolds 0c4751ba30
Fixed crash when cloud shell provider timed out or was closed waiting for login (#16364)
## Summary of the Pull Request
Cloud shell connection calls out to Azure to do a device code login.
When the polling interval is exceeded or the tab is closed, the method
doing the connection polling returns `nullptr`, and `AzureConnection`
immediately tries to `GetNamedString` from it, causing a crash. This
doesn't repro on Terminal Stable or Preview, suggesting it's pretty
recent related to the update of this azureconnection.

This is just a proposed fix, not sure if you want to do more extensive
changes to the affected class or not, so marking this as a draft.

## References and Relevant Issues
* N/A - encountered this while using the terminal myself

## PR Checklist/Validation
Tested out a local dev build:

- [x] Terminal doesn't crash when cloudshell polling interval exceeded
- [x] Terminal doesn't crash when cloudshell tab closed while polling
for Azure login
2023-11-30 03:58:41 -06:00
Marcel Wagner 3b5e5cf5f1
Update paths to use linking within repo instead of github URL (#16358)
Update paths to use relative linking instead of static GitHub link. Also
fixes some dead links

Closes #16338
2023-11-27 15:41:17 -08:00
Leonard Hecker 7a1b6f9d2a
Fix scrolling with SetConsoleWindowInfo (#16334)
81b7e54 caused a regression in `SetConsoleWindowInfo` and any other
function that used the `WriteToScreen` helper. This is because it
assumes that it can place the viewport anywhere randomly and it was
written at a time where `TriggerScroll` didn't exist yet (there was
no need for that (also not today, but that's being worked on)). 

Caching the viewport meant that `WriteToScreen`'s call to
`TriggerRedraw` would pick up the viewport from the last rendered
frame, which would cause the intersection of both to be potentially
empty and nothing to be drawn on the screen.

This commit reverts 81b7e54 as I found that it has no or negligible
impact on performance at this point, likely due to the overall
vastly better performance of conhost nowadays.

Closes #15932

## Validation Steps Performed
* Scroll the viewport by entire pages worth of content using
  `SetConsoleWindowInfo` - see #15932
* The screen and scrollbars update immediately 
2023-11-27 15:34:13 -06:00
Lonny Wong 8747a39a07
Fix Control+Space not sent to program running in terminal (#16298)
Converts null byte to specific input event, so that it's properly
delivered to the program running in the terminal.

Closes #15939
2023-11-27 15:31:06 -06:00
Leonard Hecker 35240f263e
Fix font preview for conhost (#16324)
After exiting the main loop in this function the invariant
`nFont <= NumberOfFonts` still holds true. Additionally,
preceding this removed code is this (paraphrased):
```cpp
if (nFont < NumberOfFonts) {
    RtlMoveMemory(...);
}
```
It ensures that the given slot `nFont` is always unoccupied by moving
it and all following items upwards if needed. As such, the call to
`DeleteObject` is always incorrect, as the slot is always "empty",
but may contain a copy of the previous occupant due to the `memmove`.

This regressed in 154ac2b.

Closes #16297

## Validation Steps Performed
* All fonts have a unique look in the preview panel 
2023-11-27 12:44:50 -08:00
Radu Cernatescu 0a4fc9b6e4
Fix scrollbar resetting position on save (#16261)
This PR fixes Issue #11875 by introducing a ScrollViewer and some logic
for the scrollbar.

The ScrollViewer prevents the scrollbar from scrolling to the top
whenever "Save" is clicked in the Settings. In addition, the scrollbar
is scrolled to the top of the page whenever navigating to another page
within Settings. The scrollbar will not reset if attempting to navigate
to the same page that is already navigated to.

## Validation Steps Performed
Manual testing of the Settings by building the Terminal app.

Closes #11875
2023-11-27 11:40:47 -08:00
Leonard Hecker 63b3820a18
Fix input buffering for A APIs (#16313)
This fixes an issue where character-wise reading of an input like "abc"
would return "a" to the caller, store "b" as a partial translation
(= wrong) and return "c" for the caller to store it for the next call.

Closes #16223
Closes #16299

## Validation Steps Performed
* `ReadFile` with a buffer size of 1 returns inputs character by
  character without dropping any inputs 

---------

Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
2023-11-21 20:57:56 +00:00
Marcel Wagner 264ef4ebda
[colortool] Add new campbell scheme, switch to CRLF endings for themes (#16339)
Adds "Campbell Absolute" which has absolute black/white instead of
slightly greyish variants as discussed per #35. Also updates line
endings to adhere to the default Windows line endings (i.e. CRLF)

Closes #35
2023-11-21 20:55:15 +00:00
Leonard Hecker bdf2f6f274
Fix chunked soft fonts not working (#16349)
This changeset fixes an issue caused by #15991 where "chunked" escape
sequences would get corrupted. The fix is to simply not flush eagerly
anymore. I tried my best to keep the input lag reduction from #15991,
but unfortunately this isn't possible for console APIs.

Closes #16079

## Validation Steps Performed
* `type ascii.com` produces soft font ASCII characters 
2023-11-21 20:50:59 +00:00
Leonard Hecker adb04729bc
ConPTY: Fix a shutdown deadlock with WSL (#16340)
Under normal circumstances this bug should be rare as far as I can
observe it on my system. However, it does occur randomly.

In short, WSL doesn't pass us anonymous pipes, but rather WSA sockets
and those signal their graceful shutdown first before being closed
later by returning a `lpNumberOfBytesRead` of 0 in the meantime.

Additionally, `VtIo` synchronously pumps the input pipe to get the
initial cursor position, but fails to check `_exitRequested`.
And so even with the pipe handling fixed, `VtIo` will also deadlock,
because it will never realize that `VtInputThread` is done reading.

## Validation Steps Performed
* Build commit 376737e with this change and replace conhost with it
  Coincidentally it contains a bug (of as of yet unknown origin)
  due to which the initial cursor position loop in `VtIo` never
  completes. Thanks to this, we can easily provoke this issue.
* Launch WSL in conhost and run an .exe inside it
* Close the conhost window
* Task manager shows that all conhost instances exit immediately
2023-11-21 20:50:46 +00:00
Mike Griese 12318d97d0
test: Add an LLM-powered bot to detect dupes (#16304)
Just like in https://github.com/microsoft/WSL/pull/10745

We're working with the WSL team to figure out if we can use a LLM to
help us triage. This _should_ just comment on issues, if it finds
something similar on the backlog.
2023-11-21 10:05:07 -08:00
Leonard Hecker 376737e54a
Hotfix recent AuditMode failures on CI (#16325)
Our CI seems to have had an update recently to around VS 17.7.
That version contains a faulty implementation for C26478 and C26494.
The issue has been fixed in VS 17.8 and later.
2023-11-16 15:28:37 -06:00
Leonard Hecker b780b44528
Fix nearby fonts for DxEngine again (#16323)
The nearby font loading has to be outside of the try/catch of the
`_FindFontFace` call, because it'll throw for broken font files.
But in my previous PR I had overlooked that the font variant loop
modifies the only copy of the face name that we got and was in the
same try/catch. That's bad, because once we get to the nearby search
code, the face name will be invalid. This commit fixes the issue by
wrapping each individual `_FindFontFace` call in a try/catch block.

Closes #16322

## Validation Steps Performed
* Remove every single copy of Windows Terminal from your system
* Manually clean up Cascadia .ttf files because they aren't gone
* Destroy your registry by manually removing appx references (fun!)
* Put the 4 Cascadia .ttf files into the Dev app AppX directory
* Launch
* No warning 
2023-11-16 15:27:33 -06:00
Dustin L. Howett 86fb9b4478
Add a magic incantation to tell the Store we support Server (#16306)
I find it somewhat silly that (1) this isn't documented anywhere and (2)
installing the "desktop experience" packages for Server doesn't
automatically add support for the `Windows.Desktop` platform...

Oh well.

I'm going to roll this one out via Preview first, because if the store
blows up on it I would rather it not be during Stable roll-out.
2023-11-15 17:13:03 -08:00
Dustin Howett 65e19ddaf0 Merged PR 9880704: [Git2Git] conhost: remove all EOL velocity keys
I've also removed all of the supporting code.

Related work items: MSFT-47555635

Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_we_adept_e4d2 f8ad0110fd81d1b848224158c8f95724f34b1db2
2023-11-15 21:32:10 +00:00
Dustin L. Howett 37100034bf
canary: include the correct handoff CLSIDs (#16317)
Canary still advertised the Dev CLSIDs, so it didn't work as DefTerm.

Closes #16316
2023-11-15 12:48:54 -08:00
Mike Griese 55a9874d5c Fix leak in buffering text for UIA when unfocused (#16251)
Notes in #16217 have the investigation.

TL;DR: we'd always buffer text. Even if we're disabled (unfocused). When
we're
disabled, we'd _never_ clear the buffered text. Oops.

Closes #16217

(cherry picked from commit d14524cd4c)
Service-Card-Id: 91033138
Service-Version: 1.19
2023-11-13 16:59:53 -06:00
PankajBhojwani a7409ea4d3 Update Azure Cloud Shell for their new URI format (#16247)
The Azure cloud shell team made some API changes that required us to
format our requests a little differently. This PR makes those changes
(more info in the comments in the code)

Closes #16098

(cherry picked from commit 5a9f3529d7)
Service-Card-Id: 90985893
Service-Version: 1.19
2023-11-13 16:59:53 -06:00
Dustin L. Howett 28a1ecbdaa releng: add --first-parent to the scripts that use git log (#16279)
It makes the output less cluttered and more correct (for example:
ServicingPipeline no longer tries to service two copies of each commit
if there's a merge in the history...)

(cherry picked from commit 18b0ecbb2a)
Service-Card-Id: 91042450
Service-Version: 1.19
2023-11-13 16:59:53 -06:00
Leonard Hecker 4bbfa0570a Fix deadlocks due to holding locks across WriteFile calls (#16224)
This fixes a number of bugs introduced in 4370da9, all of which are of
the same kind: Holding the terminal lock across `WriteFile` calls into
the ConPTY pipe. This is problematic, because the pipe has a tiny buffer
size of just 4KiB and ConPTY may respond on its output pipe, before the
entire buffer given to `WriteFile` has been emptied. When the ConPTY
output thread then tries to acquire the terminal lock to begin parsing
the VT output, we get ourselves a proper deadlock (cross process too!).

The solution is to tease `Terminal` further apart into code that is
thread-safe and code that isn't. Functions like `SendKeyEvent` so far
have mixed them into one, because when they get called by `ControlCore`
they both, processed the data (not thread-safe as it accesses VT state)
and also sent that data back into `ControlCore` through a callback
which then indirectly called into the `ConptyConnection` which calls
`WriteFile`. Instead, we now return the data that needs to be sent from
these functions, and `ControlCore` is free to release the lock and
then call into the connection, which may then block indefinitely.

## Validation Steps Performed
* Start nvim in WSL
* Press `i` to enter the regular Insert mode
* Paste 1MB of text
* Doesn't deadlock 

(cherry picked from commit 71a1a97a9a)
Service-Card-Id: 91043521
Service-Version: 1.19
2023-11-13 16:59:53 -06:00
Mike Griese 2ac5e8670a Defer package updates while the Terminal is running (#16250)
Adds
```xml
<uap17:UpdateWhileInUse>defer</uap17:UpdateWhileInUse>
```
to our `Package.Properties` for all our packages.
This was added in the September 2023 OS release of Windows 11.

Apparently, this just works now? I did update VS,
but I don't _think_ that updated the SDK.
I have no idea how it updated the manifest definitions.

Closes #3915
Closes #6726

(cherry picked from commit 077d63e6a3)
Service-Card-Id: 91033136
Service-Version: 1.19
2023-11-13 16:59:53 -06:00
Mike Griese d14524cd4c
Fix leak in buffering text for UIA when unfocused (#16251)
Notes in #16217 have the investigation.

TL;DR: we'd always buffer text. Even if we're disabled (unfocused). When
we're
disabled, we'd _never_ clear the buffered text. Oops.

Closes #16217
2023-11-10 02:10:35 +01:00
Tushar Singh e268c1c952
Support rendering of underline style and color (#16097)
Add support for underline style and color in the renderer

> [!IMPORTANT]  
> The PR adds underline style and color feature to AtlasEngine (WT) and
GDIRenderer (Conhost) only.

After the underline style and color feature addition to Conpty, this PR
takes it further and add support for rendering them to the screen!

Out of five underline styles, we already supported rendering for 3 of
those types (Singly, Doubly, Dotted) in some form in our (Atlas)
renderer. The PR adds the remaining types, namely, Dashed and Curly
underlines support to the renderer.

- All renderer engines now receive both gridline and underline color,
and the latter is used for drawing the underlines. **When no underline
color is set, we use the foreground color.**
- Curly underline is rendered using `sin()` within the pixel shader. 
- To draw underlines for DECDWL and DECDHL, we send the line rendition
scale within `QuadInstance`'s texcoord attribute.
- In GDI renderer, dashed and dotted underline is drawn using `HPEN`
with a desired style. Curly line is a cubic Bezier that draws one wave
per cell.

## PR Checklist
-  Set the underline color to underlines only, without affecting the
gridline color.
-  Port to DX renderer. (Not planned as DX renderer soon to be replaced
by **AtlasEngine**)
-  Port underline coloring and style to GDI renderer (Conhost).
-  Wide/Tall `CurlyUnderline` variant for `DECDWL`/`DECDHL`.

Closes #7228
2023-11-09 16:47:07 -08:00
chausner eb16eeb29e
Change DisclaimerStyle to be non-italic (#16272)
This changes the appearance of the disclaimer text that is used on some
of the settings pages. The italic text style is replaced with a neutral
style that fits better with the rest of the UI.

## Detailed Description of the Pull Request / Additional comments
I also tried out these alternative styles but overall preferred the
default TextBlock style (BodyTextBlockStyle).

Closes #16264.
2023-11-09 16:32:58 -08:00
PankajBhojwani 5a9f3529d7
Update Azure Cloud Shell for their new URI format (#16247)
The Azure cloud shell team made some API changes that required us to
format our requests a little differently. This PR makes those changes
(more info in the comments in the code)

Closes #16098
2023-11-08 09:12:13 -08:00
Dustin L. Howett 18b0ecbb2a
releng: add --first-parent to the scripts that use git log (#16279)
It makes the output less cluttered and more correct (for example:
ServicingPipeline no longer tries to service two copies of each commit
if there's a merge in the history...)
2023-11-08 10:29:01 -06:00
Leonard Hecker 71a1a97a9a
Fix deadlocks due to holding locks across WriteFile calls (#16224)
This fixes a number of bugs introduced in 4370da9, all of which are of
the same kind: Holding the terminal lock across `WriteFile` calls into
the ConPTY pipe. This is problematic, because the pipe has a tiny buffer
size of just 4KiB and ConPTY may respond on its output pipe, before the
entire buffer given to `WriteFile` has been emptied. When the ConPTY
output thread then tries to acquire the terminal lock to begin parsing
the VT output, we get ourselves a proper deadlock (cross process too!).

The solution is to tease `Terminal` further apart into code that is
thread-safe and code that isn't. Functions like `SendKeyEvent` so far
have mixed them into one, because when they get called by `ControlCore`
they both, processed the data (not thread-safe as it accesses VT state)
and also sent that data back into `ControlCore` through a callback
which then indirectly called into the `ConptyConnection` which calls
`WriteFile`. Instead, we now return the data that needs to be sent from
these functions, and `ControlCore` is free to release the lock and
then call into the connection, which may then block indefinitely.

## Validation Steps Performed
* Start nvim in WSL
* Press `i` to enter the regular Insert mode
* Paste 1MB of text
* Doesn't deadlock 
2023-11-08 10:28:07 -06:00
Mike Griese 077d63e6a3
Defer package updates while the Terminal is running (#16250)
Adds
```xml
<uap17:UpdateWhileInUse>defer</uap17:UpdateWhileInUse>
```
to our `Package.Properties` for all our packages.
This was added in the September 2023 OS release of Windows 11.

Apparently, this just works now? I did update VS,
but I don't _think_ that updated the SDK.
I have no idea how it updated the manifest definitions.

Closes #3915
Closes #6726
2023-11-07 21:35:16 +01:00
Dustin Howett 7cbe3190e1 Merged PR 9838597: Migrate OSS up to db27348e2
- AtlasEngine: Minor bug fixes (GH-16219)
- Fix the fix for the fix of nearby font loading (GH-16196)
- Added selectionBackground to light color schemes (GH-16243)
- Another theoretical fix for a crash (GH-16267)
- Fix tabs being printed in cmd.exe prompts (GH-16273)

Related work items: MSFT-47266988
2023-11-07 17:59:28 +00:00
Leonard Hecker db27348e27 Fix tabs being printed in cmd.exe prompts (#16273)
A late change in #16105 wrapped `_buffer` into a class to better track
its dirty state, but I failed to notice that in this one instance we
intentionally manipulated `_buffer` without marking it as dirty.
This fixes the issue by adding a call to `MarkAsClean()`.

This changeset also adds the test instructions from #15783 as a
document to this repository. I've extended the list with two
bugs we've found in the implementation since then.

## Validation Steps Performed
* In cmd.exe, with an empty prompt in an empty directory:
  Pressing tab produces an audible bing and prints no text 

(cherry picked from commit 7a8dd90294)
Service-Card-Id: 91033502
Service-Version: 1.19
2023-11-07 11:56:00 -06:00
Mike Griese 83a2bc181a Another theoretical fix for a crash (#16267)
For history:

> This is MSFT:46763065 internally. Dumps show this repros on 1.19 too.
>
> This was previously #16061 which had a theoretical fix in #16065.
Looks like you're on Terminal Stable v1.18.2822.0, and
https://github.com/microsoft/terminal/releases/tag/v1.18.2822.0 is
supposed to have had that fix in it. Dang.

> well this is embarrassing ... I never actually checked if we _still
had a `_window`_. We're alive, yay! But we're still in the middle of
refrigerating. So, there's no HWND anymore

Attempt to fix this by actually ensuring there's a `_window` in
`AppHost::_WindowInitializedHandler`

Closes #16235

(cherry picked from commit 59dcbbe0e9)
Service-Card-Id: 91041359
Service-Version: 1.19
2023-11-07 11:55:59 -06:00
Taha Haksal 95e4d0bbe0 Added selectionBackground to light color schemes (#16243)
Add a selectionBackground property which is set to the scheme's
brightBlack too all 3 of the light color schemes.

Related to #8716
It does not close the bug because as mentioned in the issue, when you
input numbers, they seem to be invisible in the light color schemes and
selecting them with the cursor doesn't reveal them.

(cherry picked from commit a5c269b280)
Service-Card-Id: 91033167
Service-Version: 1.19
2023-11-07 11:55:59 -06:00
Leonard Hecker a608a91571 Fix the fix for the fix of nearby font loading (#16196)
I still don't know how to reproduce it properly, but I'm slowly
wrapping my head around how and why it happens. The issue isn't that
`FindFamilyName` fails with `exists=FALSE`, but rather that any of the
followup calls like `GetDesignGlyphMetrics` fails, which results in an
exception and subsequently in an orderly fallback to Consolas.
I've always thought that the issue is that even with the nearby font
collection we get an `exists=FALSE`... I'm not sure why I thought that.

This changeset also drops the fallback iteration for Lucida Console and
Courier New, because I felt like the code looks neater that way and I
think it's a reasonable expectation that Consolas is always installed.

Closes #16058

(cherry picked from commit 9e86c9811f)
Service-Card-Id: 90885607
Service-Version: 1.19
2023-11-07 11:55:58 -06:00
Leonard Hecker 646edc7f8f AtlasEngine: Minor bug fixes (#16219)
This commit fixes 4 minor bugs:
* Forgot to set the maximum swap chain latency. Without it, it defaults
  to up to 3 frames of latency. We don't need this, because our renderer
  is simple and fast and is expected to draw frames within <1ms.
* ClearType treats the alpha channel as ignored, whereas custom shaders
  can manipulate the alpha channel freely. This meant that using both
  simultaneously would produce weird effects, like text having black
  background. We now force grayscale AA instead.
* The builtin retro shader should not be effected by the previous point.
* When the cbuffer is entirely unused in a custom shader, it has so far
  resulted in constant redraws. This happened because the D3D reflection
  `GetDesc` call will then return `E_FAIL` in this situation.
  The new code on the other hand will now assume that a failure
  to get the description is equal to the variable being unused.

Closes #15960

## Validation Steps Performed
* A custom passthrough shader works with grayscale and ClearType AA
  while also changing the opacity with Ctrl+Shift+Scroll 
* Same for the builtin retro shader, but ClearType works 
* The passthrough shader doesn't result in constant redrawing 

(cherry picked from commit 0289cb043c)
Service-Card-Id: 90915277
Service-Version: 1.19
2023-11-07 11:55:57 -06:00
Leonard Hecker 7a8dd90294
Fix tabs being printed in cmd.exe prompts (#16273)
A late change in #16105 wrapped `_buffer` into a class to better track
its dirty state, but I failed to notice that in this one instance we
intentionally manipulated `_buffer` without marking it as dirty.
This fixes the issue by adding a call to `MarkAsClean()`.

This changeset also adds the test instructions from #15783 as a
document to this repository. I've extended the list with two
bugs we've found in the implementation since then.

## Validation Steps Performed
* In cmd.exe, with an empty prompt in an empty directory:
  Pressing tab produces an audible bing and prints no text 
2023-11-07 11:51:13 -06:00
Mike Griese 59dcbbe0e9
Another theoretical fix for a crash (#16267)
For history: 

> This is MSFT:46763065 internally. Dumps show this repros on 1.19 too. 
> 
> This was previously #16061 which had a theoretical fix in #16065.
Looks like you're on Terminal Stable v1.18.2822.0, and
https://github.com/microsoft/terminal/releases/tag/v1.18.2822.0 is
supposed to have had that fix in it. Dang.

> well this is embarrassing ... I never actually checked if we _still
had a `_window`_. We're alive, yay! But we're still in the middle of
refrigerating. So, there's no HWND anymore

Attempt to fix this by actually ensuring there's a `_window` in
`AppHost::_WindowInitializedHandler`

Closes #16235
2023-11-06 22:45:24 +00:00
Taha Haksal a5c269b280
Added selectionBackground to light color schemes (#16243)
Add a selectionBackground property which is set to the scheme's
brightBlack too all 3 of the light color schemes.

Related to #8716
It does not close the bug because as mentioned in the issue, when you
input numbers, they seem to be invisible in the light color schemes and
selecting them with the cursor doesn't reveal them.
2023-11-06 14:42:56 -08:00
Leonard Hecker 17cc109081
Remove conhost telemetry (#16253)
The `Telemetry` class was implemented as a singleton which stood in
my long-term goal to remove all global variables from the project.
Most telemetry captured by it hasn't been looked at for a long time
and just as much is now pointless (e.g.,`_fCtrlPgUpPgDnUsed`).
This removes the code.

## Validation Steps Performed
* Still compiles 
2023-11-06 22:00:40 +00:00
Leonard Hecker 9e86c9811f
Fix the fix for the fix of nearby font loading (#16196)
I still don't know how to reproduce it properly, but I'm slowly
wrapping my head around how and why it happens. The issue isn't that
`FindFamilyName` fails with `exists=FALSE`, but rather that any of the
followup calls like `GetDesignGlyphMetrics` fails, which results in an
exception and subsequently in an orderly fallback to Consolas.
I've always thought that the issue is that even with the nearby font
collection we get an `exists=FALSE`... I'm not sure why I thought that.

This changeset also drops the fallback iteration for Lucida Console and
Courier New, because I felt like the code looks neater that way and I
think it's a reasonable expectation that Consolas is always installed.

Closes #16058
2023-11-06 15:30:03 -06:00
Leonard Hecker 0289cb043c
AtlasEngine: Minor bug fixes (#16219)
This commit fixes 4 minor bugs:
* Forgot to set the maximum swap chain latency. Without it, it defaults
  to up to 3 frames of latency. We don't need this, because our renderer
  is simple and fast and is expected to draw frames within <1ms.
* ClearType treats the alpha channel as ignored, whereas custom shaders
  can manipulate the alpha channel freely. This meant that using both
  simultaneously would produce weird effects, like text having black
  background. We now force grayscale AA instead.
* The builtin retro shader should not be effected by the previous point.
* When the cbuffer is entirely unused in a custom shader, it has so far
  resulted in constant redraws. This happened because the D3D reflection
  `GetDesc` call will then return `E_FAIL` in this situation.
  The new code on the other hand will now assume that a failure
  to get the description is equal to the variable being unused.

Closes #15960

## Validation Steps Performed
* A custom passthrough shader works with grayscale and ClearType AA
  while also changing the opacity with Ctrl+Shift+Scroll 
* Same for the builtin retro shader, but ClearType works 
* The passthrough shader doesn't result in constant redrawing 
2023-10-31 14:25:41 +01:00