4238 Commits

Author SHA1 Message Date
Mike Griese
174dcb9091
Add an experimental setting for making suggestions RGB (#17416)
Adds `$profile:experimental.rainbowSuggestions`, which makes the
suggestion text all RGB. This sparks joy.
2024-06-25 17:44:56 -05:00
Windows Console Service Bot
9f7032afd8
Localization Updates - builtin glyphs/shader compilation (#17458) 2024-06-24 13:03:25 -07:00
Leonard Hecker
8c14a34263
Fix builtin glyph corruption in the D2D renderer (#17464)
The initial contents of a texture are undefined. That's not good.
Now they are. That's good.
2024-06-23 10:09:42 +00:00
Leonard Hecker
bb4981caae
Add more ConsoleBench tests (#17441)
This now covers all major Console APIs.
In the future we could add tests that cover VT sequences as well.
2024-06-22 11:30:18 +00:00
Mike Griese
8511f3d737
Add a spec for "Snippets" (#17329)
This specs out a lot of plans for snippets. We've already got these in
the sxnui as "tasks", but we can do so very much more.

This spec is a few years old now, but it's time for it to get promoted
out of my draft branch.

References: 
* #1595
* #7039
* #3121
* #10436
* #12927
* #12857
* #5790
* #15845

---------

Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
2024-06-22 11:03:04 +00:00
blitzRahul
fa407332a5
Display useful pixel shader compilation errors (#17436)
More descriptive warnings are triggered when custom pixel shader
compilation fails.

If D3DCompileFromFile fails and the compiler generates an error message-
the message is converted to a wstring and is sent as a parameter when
calling p.warningCallback.
Changes were made to resources.resw and TermControl.cpp to accommodate
this.

## Validation Steps Performed
I tested the following errors that may be encountered while developing a
custom pixel shader:
1. Compile time errors
2. File not found error
3. Path not found error
4. Access denied error

Fixes #17435

TAEF tests passed:
Summary: Total=294, Passed=294, Failed=0, Blocked=0, Not Run=0,
Skipped=0
2024-06-21 21:25:49 +00:00
Dustin L. Howett
34d4dc5a5f
Remove the D2D warning from the Builtin Glyphs setting (#17454) 2024-06-20 14:03:27 -07:00
David Federman
613a539613
Add Microsoft.MSBuildCache (#17393)
Add Microsoft.MSBuildCache

This change adds a new pipeline which enables caching in the build. This
is added as a separate pipeline for now with the eventual goal of
enabling for PR and/or CI builds.

Documentation for Microsoft.MSBuildCache can be found in the GitHub
repo: https://github.com/microsoft/MSBuildCache

Preliminary numbers below.

*
[Baseline](https://dev.azure.com/ms/terminal/_build/results?buildId=579399&view=results):
12 min
* [0% Cache
hits](https://dev.azure.com/ms/terminal/_build/results?buildId=579419&view=results):
16 mins
* [100% cache
hits](https://dev.azure.com/ms/terminal/_build/results?buildId=579427&view=results):
3 mins
2024-06-20 14:02:26 -07:00
Leonard Hecker
bd116e35b2
Make the renderer optional (#17442)
If `VtEngine` gets removed from conhost, we need to be able to run
without any renderer present whatsoever. To make this possible,
I've turned all `Renderer&` into `Renderer*`.

Part of #14000
2024-06-20 18:26:58 +00:00
Leonard Hecker
e0686fa6f3
Remove some unused TextBuffer methods (#17443)
This is simply some unused code from the days before the big
text buffer rewrite in #13626.
2024-06-20 16:55:22 +00:00
Leonard Hecker
324e0f425a
Move colorbrewer into its own proper header (#17444)
I'm planning to use the `dark2` color palette in the upcoming
cooked read rewrite as a debug aid to paint dirty regions.
Now that it's going to be used in more than one place I figured
it may be time to properly add it to the NOTICE file even if
it still won't be shipped with the final product.
2024-06-20 16:55:13 +00:00
PankajBhojwani
5d46e317b2
Fix crash when closing panes very quickly (#17450)
#17358 introduced a bug where if you open/close panes very rapidly
Terminal will crash. This was because `_content` was being set to `null`
and then a `Close` event was being emitted, but several functions
attempt to access the pane's `_content` as part of the close routine.
For example, `TerminalTab` tries to update the `TaskbarProgress` every
time a pane is closed and as part of that update sequence it queries the
pane - which has `null` content now - for the taskbar progress,
resulting in a crash. This PR fixes that crash.

Refs #17358
2024-06-20 16:07:40 +00:00
Dustin L. Howett
a80539c2f7
build: make the agent pool selection more robust (#17440) 2024-06-19 10:13:52 -05:00
Dustin L. Howett
f1079be854
ci: Remove GitHub Rich Code Nav Indexer (#17438)
It's been throwing deprecation warnings for a while, and now I can't
install the task on our new Azure Organization
2024-06-18 08:40:15 -07:00
Windows Console Service Bot
227cfdefac
Localization Updates - main - 06/12/2024 03:05:48 (#17423) 2024-06-13 15:36:59 -05:00
Tushar Singh
7c1e2298f8
Fix some search highlights scenarios (#17352)
Fixes:
- Snapping the current match to the current selection doesn't work.
- Fast closing and re-opening SearchBox would leave search highlights in
an inconsistent state. The highlights would be active even when SB is
not on the screen, and results are not updated as more text is added to
the buffer.
- Search highlights scroll marks are not cleared when the search box is
closed.
2024-06-13 18:29:12 +00:00
Mike Griese
a7e2b46e20
Add descriptions to commands (namely, snippets) (#17376)
This adds a `"description"` property to actions. Notably, the shell
completion protocol (#3121) will now also populate that.

The suggestions UI can then use those descriptions to display an
additional tooltip with that information.

TeachingTip was kinda an abject disaster last time I tried this, so this
_isn't_ a TeachingTip. It's literally a text block.

xlinks:
* #13000
* #15845 
* #14939 - the last abandoned attempt at this
2024-06-12 20:03:22 +00:00
Mike Griese
86ba98607f
Re-implement previewing, with the new TSF (#17386)
This adds support for previewing snippets, again. This time, with the
new TSF implementation. Leonard pointed me in the right direction with
this - he's the one who suggested to have a second `Composition` just
for previews like this.

Then we do some tricky magic to make it work when we're using
commandlines from shell integration, or you've got the ghost text from
powershell, etc. Then we visualize the control codes, just so they
aren't just U+FFFE diamonds.

Closes #12861
2024-06-11 23:18:18 +00:00
Carlos Zamora
125738b63e
Add Spec for Quick Fix (#17005)
Quick Fix will be a new UI surface that allows the user to interact with
the terminal and leverage the context of a specific command being
executed. This new UI surface will be a home for features like WinGet
Command Not Found.

#16599
2024-06-11 13:37:09 -05:00
flyingcat
c52ba7dec6
Make subsequent windows open in the foreground (#17368)
Sometimes subsequent WT windows open in the background behind other
applications. This PR tries to fix it.

Refs #15895
Refs #15479

Mysterious bug (and annoying). There are even some discussions about
happening to the first startup, not just subsequent ones. Sometimes the
window may show up without animation too. So I don't think this is the
final solution, but it did get solved on my computer, for now.

## Validation Steps Performed
0. Quit all WT windows if some.
1. Open File Explorer, click "Open in Terminal" in context menu.
2. Move the newly opened window and minimize it.
3. Back to step 1 and repeat several times.
4. All the windows should open in the foreground correctly (yet possibly
without animation).

---------

Co-authored-by: Mike Griese <migrie@microsoft.com>
2024-06-10 21:19:07 +00:00
Mike Griese
e49afb3ccd
Mark the AdaptDispatch ctor as noexcept (#17417)
CI is complaining about this on all new builds, in audit mode. But I
don't think anything changed here recently. Maybe just new audit rules
rolled out?
2024-06-10 20:52:29 +00:00
Windows Console Service Bot
5359e71ca1
Localization Updates for #17369 (#17380) 2024-06-10 14:49:08 -05:00
Dustin L. Howett
523af87e34
build: add a caching copy of the CI pipeline (#17392)
This is a place for @dfederm to work, but I couldn't create the pipeline
definition without first creating the yml file _in main_. Thanks SFI.
2024-06-07 13:13:32 -05:00
PankajBhojwani
aeed0782bc
Allow actions in the new tab dropdown (#17281)
Allows the user to define entries in the new tab menu that execute
actions, based on their action Id

Closes #3759
Closes #9362
2024-06-06 22:17:18 +00:00
PankajBhojwani
d6b6aacb4f
Remove command's knowledge of its keys (#17215)
With the move to Action IDs, it doesn't quite make sense anymore for a
`Command` to know which keys map to it. This PR removes all `Keys` from
`Command`, and any callers to that now instead query the `ActionMap` for
that Command's keys.


Closes #17160 
Closes #13943
2024-06-06 20:48:07 +00:00
Leonard Hecker
9317d42045
Warn when using old MacType versions (#17369)
This adds a check for whether MacType is injected and whether it's
a known bad version (pre-2023). In that case we avoid calling the
known faulty `ID2D1Device4` interface. We could avoid it in general to
fix the issue without a warning (it's only a very mild optimization),
but on the other hand, the bug that MacType has is a very serious one
and it's probably better overall to suggest users to update.

See: https://github.com/snowie2000/mactype/pull/938

## Validation Steps Performed
* MacType 2021.1-RC1 results in a warning and no crash 
* MacType 2023.5.31 results in no warning 

---------

Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
2024-06-05 19:16:47 +00:00
Leonard Hecker
640424e03f
Fix spurious clear-to-end sequence in buffer dumps (#17374)
I think I forgot to complete that section of the code...
The parentheses were missing and `beg` was repeated twice. The last
line in the comment above this explains what I intended it to be.

Closes #17365

## Validation Steps Performed
* In a new PowerShell tab
* Run ``"`e[999C`e[2D`e[42mfoo`e[m"``
* Newline until it scrolls
* Run it again
* Close and reopen
* The green "foo" is still green 
2024-06-05 19:14:20 +00:00
Windows Console Service Bot
13568e6b73
Localization Updates - main - regex search (#17349) 2024-06-05 12:57:55 -05:00
Leonard Hecker
261a3fec7a
Support valid out-of-bounds access in utextAccess (#17361)
`utextAccess` apparently doesn't actually need to clamp the
`chunkOffset` to be in range of the current chunk. Also, I missed to
implement the part of the spec that says to leave the iterator on the
first/last chunk of the `UText` in case of an out-of-bounds index.

This PR fixes the issue by simply not returning early, doing a more
liberal clamp of the offset, and then checking whether it was in range.

As an aside, this also fixes a one-off bug when hovering URLs that
end on the very last cell of the viewport (or are cut off).

Closes #17343

## Validation Steps Performed
* Write an URL that wraps across the last 2 lines in the buffer
* Scroll 1 line up
* No assert 
* Hovering the URL shows the full, still visible parts of the URL 
2024-06-05 17:07:59 +00:00
Leonard Hecker
ce0f8d6db2
Fix two panes being closed when just one is (#17358)
#17333 introduced a regression: While it fixes a recursion *into*
`Pane::Close()` that doesn't fix the recursion outside of it.
In this case, `Close()` raises the `Closed` event which results
in another tab being closed because it's bound to `_RemoveTab`.
The recursion is now obvious, because I made the entire process
synchronous. Previously, it would (hopefully) just be scheduled
after the pane and its content are already gone.

The issue can be fixed by moving the recursion check from
`Pane::Close()` to `TerminalTab::Shutdown()` but I felt like
it would better to fix the issue a bit more thoroughly.

`IPaneContent` can raise a `CloseRequested` event to indicate it wants
to be closed. However, that also contained recursion, because the
content would call its own `Close()` to raise the event, which the
tab catches, calls `Close()` on the `Pane` which calls `Close()` on
the content which raises the event again and so on. That's what was
fixed in #17333 among others. We can do this better by not raising
the event from `IPaneContent::Close()`. Instead, that method will now
be exclusively called by `Pane`. The `CloseRequested` event will now
truly be just a request and nothing more. Furthermore, the ownership
of the event handling was moved from the `TerminalTab` to the `Pane`.

To make all of this a bit simpler and more robust, two new methods
were added to `Pane`: `_takePaneContent` and `_setPaneContent`.
These methods ensure that `Close()` is called on the content,
that the event handlers are always added and revoked
and that the ownership transfers cleanly between panes.

## Validation Steps Performed
* Open 3 tabs, close the middle one 
* Open 3 vertical panes, close the middle one 
* Drag tabs with multiple panes between windows 
2024-06-04 18:58:37 +00:00
PankajBhojwani
ece0c04c38
Refactor ActionMap and Command to use ActionIDs (#17162)
As outlined in #16816, refactor `ActionMap` to use the new action IDs
added in #16904

## Validation steps performed

- [x] Legacy style commands are parsed correctly (and rewritten to the
new format)
- [x] Actions are still layered correctly and their IDs can be used to
'overwrite' actions in earlier layers
- [x] Keybindings that refer to an ID defined in another layer work
correctly
- [x] User-defined actions without an ID have one generated for them
(and their settings file is edited with it)
- [x] Schema updated

Refs #16816 
Closes #17133
2024-06-04 00:23:51 +00:00
James Holderness
babd344816
Account for viewport movement when wrapping over multiple rows (#17353)
## Summary of the Pull Request

When we receive a stream of output at the bottom of the page that wraps
over more than two lines, that is expected to pan the viewport down by
multiple rows to accommodate all of the output. However, when the output
is received in a single write, that did not work correctly.

The problem was that we were reusing a `Page` instance across multiple
`_DoLineFeed` calls, and the viewport cached in that `Page` wasn't valid
after the first call. This PR fixes the issue by adjusting the cached
viewport when we determine it has been moved by `_DoLineFeed`.

## References and Relevant Issues

The bug was introduced in PR #16615 when paging support was added.

## Validation Steps Performed

I've verified that the test case in #17351 is now working correctly, and
have added a unit test covering this scenario.

## PR Checklist
- [x] Closes #17351
- [x] Tests added/passed
2024-06-03 22:12:09 +00:00
Mike Griese
01e4df152e
Replace tab.ActivePaneChanged handler with a method (#17331)
I noticed this while working on #17330. We're constructing a whole
lambda just to do this wacky weak_ref logic, and that feels... gross. We
should just make this a bound method and a typed event, so we can just
use the one event handler regardless
2024-05-31 19:00:32 +00:00
Dustin L. Howett
ecb5631476
Add support for regex search to conhost and Terminal (#17316)
This is broken down into individual reviewable commits.

[Here
is](https://github.com/microsoft/terminal/assets/189190/3b2ffd50-1350-4f3c-86b0-75abbd846969)
a video of it in action!

Part of #3920
2024-05-31 11:17:16 +00:00
Leonard Hecker
baba406a07
Fix a crash when closing panes (#17333)
Calling Close() from within WalkPanes is not safe. Simply using
_FindPane is enough to fix this.

This PR also fixes another potential source of infinite recursion, and
fixes panes being passed by-value into the callbacks.

Closes #17305

## Validation Steps Performed
* Split panes vertically 3 times
* `exit` the middle, the bottom and final one, in that order
* Doesn't crash 
2024-05-30 15:00:56 +00:00
Leonard Hecker
bdc7c4fdbc
Show parts of the scrollback on restore (#17334)
First, this makes use of `PSEUDOCONSOLE_INHERIT_CURSOR` to stop ConPTY
from emitting a CSI 2 J on startup. Then, it uses
`Terminal::SetViewportPosition` to fake-scroll the viewport down so that
only 3 lines of scrollback are visible. It avoids printing actual
newlines because if we later change the text buffer to actually track
the written contents, we don't want those newlines to end up in the next
buffer snapshot.

Closes #17274

## Validation Steps Performed
* Restore cmd multiple times
* There's always exactly 3 lines visible 
2024-05-30 14:25:02 +00:00
James Holderness
ad362fc866
Position the conpty cursor correctly when wrappedRow is set (#17290)
## Summary of the Pull Request

If the VT render engine is moving the cursor to the start of a row, and
the previous row was marked as wrapped, it will assume that it doesn't
need to do anything, because the next output should automatically move
the cursor to the correct position anyway.

However, if that cursor movement is coming from the final `PaintCursor`
call for the frame, there isn't going to be any more output, so the
cursor will be left in the wrong position.

This PR fixes that issue by clearing the `_wrappedRow` field before the
`_MoveCursor` call in the `PaintCursor` method.

## Validation Steps Performed

I've confirmed that this fixes all the test cases mentioned in issue
#17270, and issue #17013, and I've added a unit test to check the new
behavior is working as expected.

However, this change does break a couple of `ConptyRoundtripTests` that
were expecting the terminal row to be marked as wrapped when writing a
wrapped line in two parts using `WriteCharsLegacy`. This is because the
legacy way of wrapping a line isn't the same as a VT delayed wrap, so it
has to be emulated with cursor movement, and that can end up resetting
the wrap flag.

It's possible that could be fixed, but it's already broken in a number
of other ways, so I don't think this makes things much worse. For now,
I've just made the affected test cases skip the wrapping check.

## PR Checklist
- [x] Closes #17013
- [x] Closes #17270
- [x] Tests added/passed
2024-05-30 14:20:19 +00:00
Mike Griese
a7c99beb6b
Remove the animations from the command palette too (#17335)
Exactly the same as #17247, but also just applied to the command
palette. It's so much better guys.
2024-05-29 23:30:08 +00:00
Leonard Hecker
0bd0eeabcb
Cursor coordinates are viewport-relative (#17332)
The changeset is rather self-explanatory.
Some things in the rendering code are in
absolute and some things are in relative
coordinates. Cursor coordinates belong to
the latter. It's a bit confusing.

Closes #17310

## Validation Steps Performed
* Use the GDI text renderer
* Use cmd
* Press and hold Enter
* No more ghostly cursors 
2024-05-29 17:33:14 +00:00
Windows Console Service Bot
13de7c6685
Localization Updates - fix issues in Korean, Italian, Spanish (#17304)
Closes #12665 
Closes #12712 
Closes #16867
2024-05-28 17:29:23 +00:00
Tushar Singh
212f43e7fb
Fix hyperlinks using an extra character at the end (#17326)
Closes: #17323 

## Validation Steps Performed
- Run `echo Hello ^(https://github.com/microsoft/terminal^)` in cmd.
- Ctrl+click on the URL opens `https://github.com/microsoft/terminal` in
the browser.
- Hovering over the url in the terminal shows
`https://github.com/microsoft/terminal` in the hover UI.
2024-05-28 17:00:55 +00:00
Mike Griese
5d1cf1a704
Raise the dupe bot's threshold to .8 (#17318)
I was talking with @plante-msft this week at Build and we agreed that
.75 is just a bit too chatty. .8 seems like it's a better threshold -
sure, it'll miss a few of the harder edge cases, but it'll chime in less
frequently when it's just wrong.
2024-05-24 13:28:28 -05:00
James Holderness
e826203bb7
Remove some unused/obsolete XtermEngine code (#17287)
## Summary of the Pull Request

The dirty view calculation in the `XtermEngine::StartPaint` method was
originally used to detect a full frame paint that would require a clear
screen, but that code was removed as part of PR #4741, making this
calculation obsolete.

The `performedSoftWrap` variable in the `XtermEngine::_MoveCursor`
method was assumedly a remanent of some WIP code that was mistakenly
committed in PR #5181. The variable was never actually used.

## Validation Steps Performed

All the unit tests still pass and nothing seems obviously broken in
manual testing.

## PR Checklist
- [x] Closes #17280
2024-05-20 17:53:39 +00:00
James Holderness
4a243f0445
Add support for VT paging operations (#16615)
This PR adds support for multiples pages in the VT architecture, along
with new operations for moving between those pages: `NP` (Next Page),
`PP` (Preceding Page), `PPA` (Page Position Absolute), `PPR` (Page
Position Relative), and `PPB` (Page Position Back).

There's also a new mode, `DECPCCM` (Page Cursor Coupling Mode), which
determines whether or not the active page is also the visible page, and
a new query sequence, `DECRQDE` (Request Displayed Extent), which can be
used to query the visible page.

## References and Relevant Issues

When combined with `DECCRA` (Copy Rectangular Area), which can copy
between pages, you can layer content on top of existing output, and
still restore the original data afterwards. So this could serve as an
alternative solution to #10810.

## Detailed Description of the Pull Request / Additional comments

On the original DEC terminals that supported paging, you couldn't have
both paging and scrollback at the same time - only the one or the other.
But modern terminals typically allow both, so we support that too.

The way it works, the currently visible page will be attached to the
scrollback, and any content that scrolls off the top will thus be saved.
But the background pages will not have scrollback, so their content is
lost if it scrolls off the top.

And when the screen is resized, only the visible page will be reflowed.
Background pages are not affected by a resize until they become active.
At that point they just receive the traditional style of resize, where
the content is clipped or padded to match the new dimensions.

I'm not sure this is the best way to handle resizing, but we can always
consider other approaches once people have had a chance to try it out.

## Validation Steps Performed

I've added some unit tests covering the new operations, and also done a
lot of manual testing.

Closes #13892
Tests added/passed
2024-05-17 21:49:23 +00:00
Dustin L. Howett
097a2c1136
Revert Canary to supporting 10.0.19041 (Windows 10 Vb+) (#17284)
The 2024.04D servicing update to Windows 10 added support for
`appLicensing`.
2024-05-17 15:46:52 -05:00
Windows Console Service Bot
26cc5da7f1
Localization Updates - main - associated with #17259 (#17272) 2024-05-17 12:42:09 -05:00
Leonard Hecker
3486111722
AtlasEngine: Implement remaining underlines and builtin glyphs for D2D (#17278)
This implements builtin glyphs for our Direct2D renderer, as well as
dashed and curly underlines. With this in place the only two features
it doesn't support are inverted cursors and VT soft fonts.
This allows us to remove the `_hack*` members introduced in a6a0e44.

The implementation of dashed underlines is trivial, while curly
underlines use quadratic bezier curves. Caching the curve as a sprite
is possible, however I feel like that can be done in the future.

Builtin glyphs on the other hand require a cache, because otherwise
filling the entire viewport with shaded glyphs would result in poor
performance. This is why it's built on top of `ID2D1SpriteBatch`.
Unfortunately the API causes an eager flush of other pending graphics
instructions, which is why there's still a decent perf hit.

Finally, as a little extra, this fixes the rounded powerline glyph
shapes being slightly cut off. The fix is to simply don't round the
position and radius of the ellipsis/semi-circle.

Closes #17224

## Validation Steps Performed
* RenderingTests.exe updated 
* All supported builtin glyphs look sorta right at different sizes 
2024-05-16 23:41:48 +00:00
Leonard Hecker
183a8956f6
Fix lock warning during ReturnResponse (#17266)
As reported here:
https://github.com/microsoft/terminal/pull/16224#discussion_r1594849244

The underlying `WriteFile` call may block indefinitely and
we shouldn't hold the terminal lock during that period.
2024-05-15 22:03:28 +00:00
Leonard Hecker
9054c81934
Fix persistence of handoff'd tabs (#17268)
As it turns out, for handoff'd connections `Initialize` isn't called
and this meant the `_sessionId` was always null.
After this PR we still don't have a `_profileGuid` but that's probably
not a critical issue, since that's an inherent flaw with handoff.
It can only be solved in a robust manner if WT gets launched before the
console app is launched, but it's unlikely for that to ever happen.

## Validation Steps Performed
* Launch
* Register that version of WT as the default
* Close all tabs (Ctrl+Shift+W)
* `persistedWindowLayouts` is empty 
* Launch cmd/pwsh via handoff
* You get 1 window 
* Close the window (= press the X button)
* Launch
* You get 2 windows 
2024-05-15 22:03:04 +00:00
Leonard Hecker
f62d2d5d2c
AtlasEngine: Improve robustness against weird font sizes (#17258)
This clamps the font sizes between 1 and 100. Additionally, it fixes
a warning that I randomly noticed when reproducing the issue: D2D
complained that `EndDraw` must be called before releasing resources.
Finally, this fixes a crash when the terminal size is exactly (1,1)
cells, which happened because the initial (invalid) size was (1,1) too.

This doesn't fully fix all font-size related issues, but that's
currently difficult to achieve, as for instance the swap chain size
isn't actually based on the window size, nay, it's based on the cell
size multiplied by the cell count. So if the cell size is egregiously
large then we get a swap chain size that's larger than the display and
potentially larger than what the GPU supports which results in errors.

Closes #17227
2024-05-14 19:26:16 +00:00