Skip to content

Commit

Permalink
Merge branch 'main' into dev/cazamor/sui/compatibility-0age
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Sep 24, 2024
2 parents c694620 + 4259ce5 commit 053477d
Show file tree
Hide file tree
Showing 40 changed files with 235 additions and 161 deletions.
2 changes: 1 addition & 1 deletion build/config/tsa.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"instanceUrl": "https://microsoft.visualstudio.com",
"projectName": "OS",
"areaPath": "OS\\Windows Client and Services\\ADEPT\\E4D-Engineered for Developers\\SHINE\\Terminal",
"areaPath": "OS\\Windows Client and Services\\WinPD\\DEEP-Developer Experience, Ecosystem and Partnerships\\SHINE\\Terminal",
"notificationAliases": ["[email protected]", "[email protected]"]
}
5 changes: 1 addition & 4 deletions build/pipelines/templates-v2/job-build-package-wpf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ jobs:
submodules: true
persistCredentials: True

- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: steps-setup-versioning.yml

- template: steps-download-bin-dir-artifact.yml
parameters:
Expand Down
7 changes: 3 additions & 4 deletions build/pipelines/templates-v2/job-merge-msix-into-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ jobs:
fetchTags: false # Tags still result in depth > 1 fetch; we don't need them here
submodules: true
persistCredentials: True
- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true

- template: steps-setup-versioning.yml

- template: steps-download-bin-dir-artifact.yml
parameters:
buildPlatforms: ${{ parameters.buildPlatforms }}
Expand Down
5 changes: 1 addition & 4 deletions build/pipelines/templates-v2/job-package-conpty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ jobs:
submodules: true
persistCredentials: True

- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: steps-setup-versioning.yml

- template: steps-download-bin-dir-artifact.yml
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ jobs:
submodules: true
persistCredentials: True

- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: steps-setup-versioning.yml

- task: DownloadPipelineArtifact@2
displayName: Download all PDBs from all prior build phases
Expand Down
5 changes: 1 addition & 4 deletions build/pipelines/templates-v2/job-publish-symbols.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ jobs:
submodules: true
persistCredentials: True

- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: steps-setup-versioning.yml

- task: DownloadPipelineArtifact@2
displayName: Download all PDBs from all prior build phases
Expand Down
5 changes: 1 addition & 4 deletions build/pipelines/templates-v2/job-submit-windows-vpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ jobs:
submodules: true
persistCredentials: True

- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: steps-setup-versioning.yml

- task: DownloadPipelineArtifact@2
displayName: Download MSIX Bundle Artifact
Expand Down
10 changes: 2 additions & 8 deletions build/pipelines/templates-v2/pipeline-full-release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ stages:
generateSbom: ${{ parameters.generateSbom }}
codeSign: ${{ parameters.codeSign }}
beforeBuildSteps: # Right before we build, lay down the universal package and localizations
- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: ./build/pipelines/templates-v2/steps-setup-versioning.yml@self

- task: UniversalPackages@0
displayName: Download terminal-internal Universal Package
Expand All @@ -119,10 +116,7 @@ stages:
generateSbom: ${{ parameters.generateSbom }}
codeSign: ${{ parameters.codeSign }}
beforeBuildSteps:
- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: ./build/pipelines/templates-v2/steps-setup-versioning.yml@self
# WPF doesn't need the localizations or the universal package, but if it does... put them here.

- stage: Package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ extends:
codeSign: ${{ parameters.codeSign }}
signingIdentity: ${{ parameters.signingIdentity }}
beforeBuildSteps: # Right before we build, lay down the universal package and localizations
- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: ./build/pipelines/templates-v2/steps-setup-versioning.yml@self

- task: UniversalPackages@0
displayName: Download terminal-internal Universal Package
Expand Down Expand Up @@ -167,10 +164,7 @@ extends:
codeSign: ${{ parameters.codeSign }}
signingIdentity: ${{ parameters.signingIdentity }}
beforeBuildSteps:
- task: PkgESSetupBuild@12
displayName: Package ES - Setup Build
inputs:
disableOutputRedirect: true
- template: ./build/pipelines/templates-v2/steps-setup-versioning.yml@self
# WPF doesn't need the localizations or the universal package, but if it does... put them here.

- stage: Package
Expand Down
6 changes: 6 additions & 0 deletions build/pipelines/templates-v2/steps-setup-versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- pwsh: |-
nuget install Microsoft.Windows.Terminal.Versioning -OutputDirectory _versioning
$VersionRoot = (Get-Item _versioning\Microsoft.Windows.*).FullName
& "$VersionRoot\build\Setup.ps1" -ProjectDirectory "$(Build.SourcesDirectory)" -Verbose
displayName: Set up versioning via M.W.T.V
10 changes: 5 additions & 5 deletions src/buffer/out/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool Search::IsStale(const Microsoft::Console::Render::IRenderData& renderData,
_lastMutationId != renderData.GetTextBuffer().GetLastMutationId();
}

bool Search::Reset(Microsoft::Console::Render::IRenderData& renderData, const std::wstring_view& needle, SearchFlag flags, bool reverse)
void Search::Reset(Microsoft::Console::Render::IRenderData& renderData, const std::wstring_view& needle, SearchFlag flags, bool reverse)
{
const auto& textBuffer = renderData.GetTextBuffer();

Expand All @@ -30,15 +30,15 @@ bool Search::Reset(Microsoft::Console::Render::IRenderData& renderData, const st
_results = std::move(result).value_or(std::vector<til::point_span>{});
_index = reverse ? gsl::narrow_cast<ptrdiff_t>(_results.size()) - 1 : 0;
_step = reverse ? -1 : 1;
return true;
}

void Search::MoveToCurrentSelection()
{
if (_renderData->IsSelectionActive())
{
MoveToPoint(_renderData->GetTextBuffer().ScreenToBufferPosition(_renderData->GetSelectionAnchor()));
}
else if (const auto span = _renderData->GetSearchHighlightFocused())
{
MoveToPoint(_step > 0 ? span->start : span->end);
}
}

void Search::MoveToPoint(const til::point anchor) noexcept
Expand Down
3 changes: 1 addition & 2 deletions src/buffer/out/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class Search final
Search() = default;

bool IsStale(const Microsoft::Console::Render::IRenderData& renderData, const std::wstring_view& needle, SearchFlag flags) const noexcept;
bool Reset(Microsoft::Console::Render::IRenderData& renderData, const std::wstring_view& needle, SearchFlag flags, bool reverse);
void Reset(Microsoft::Console::Render::IRenderData& renderData, const std::wstring_view& needle, SearchFlag flags, bool reverse);

void MoveToCurrentSelection();
void MoveToPoint(til::point anchor) noexcept;
void MovePastPoint(til::point anchor) noexcept;
void FindNext(bool reverse) noexcept;
Expand Down
9 changes: 2 additions & 7 deletions src/buffer/out/textBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,22 +451,17 @@ size_t TextBuffer::FitTextIntoColumns(const std::wstring_view& chars, til::Coord
cwd.GraphemeNext(state, chars);
col += state.width;

// If we ran out of columns, we need to always return `columnLimit` and not `cols`,
// because if we tried inserting a wide glyph into just 1 remaining column it will
// fail to fit, but that remaining column still has been used up. When the caller sees
// `columns == columnLimit` they will line-wrap and continue inserting into the next row.
if (col > columnLimit)
{
columns = columnLimit;
return dist;
break;
}

dist += state.len;
}

// But if we simply ran out of text we just need to return the actual number of columns.
columns = col;
return chars.size();
return dist;
}

// Pretend as if `position` is a regular cursor in the TextBuffer.
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2956,13 +2956,13 @@ bool Pane::ContainsReadOnly() const
// - <none>
void Pane::CollectTaskbarStates(std::vector<winrt::TerminalApp::TaskbarState>& states)
{
if (_IsLeaf())
if (_content)
{
auto tbState{ winrt::make<winrt::TerminalApp::implementation::TaskbarState>(_content.TaskbarState(),
_content.TaskbarProgress()) };
states.push_back(tbState);
}
else
else if (_firstChild && _secondChild)
{
_firstChild->CollectTaskbarStates(states);
_secondChild->CollectTaskbarStates(states);
Expand Down
68 changes: 34 additions & 34 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,38 +1697,41 @@ namespace winrt::Microsoft::Terminal::Control::implementation
SearchResults ControlCore::Search(SearchRequest request)
{
const auto lock = _terminal->LockForWriting();

SearchFlag flags{};
WI_SetFlagIf(flags, SearchFlag::CaseInsensitive, !request.CaseSensitive);
WI_SetFlagIf(flags, SearchFlag::RegularExpression, request.RegularExpression);
const auto searchInvalidated = _searcher.IsStale(*_terminal.get(), request.Text, flags);

if (searchInvalidated || !request.Reset)
if (searchInvalidated || !request.ResetOnly)
{
std::vector<til::point_span> oldResults;
til::point_span oldFocused;

if (const auto focused = _terminal->GetSearchHighlightFocused())
{
oldFocused = *focused;
}

if (searchInvalidated)
{
oldResults = _searcher.ExtractResults();
_searcher.Reset(*_terminal.get(), request.Text, flags, !request.GoForward);

if (SnapSearchResultToSelection())
{
_searcher.MoveToCurrentSelection();
SnapSearchResultToSelection(false);
}

_terminal->SetSearchHighlights(_searcher.Results());
}
else

if (!request.ResetOnly)
{
_searcher.FindNext(!request.GoForward);
}

if (const auto idx = _searcher.CurrentMatch(); idx >= 0)
_terminal->SetSearchHighlightFocused(gsl::narrow<size_t>(std::max<ptrdiff_t>(0, _searcher.CurrentMatch())));
_renderer->TriggerSearchHighlight(oldResults);

if (const auto focused = _terminal->GetSearchHighlightFocused(); focused && *focused != oldFocused)
{
_terminal->SetSearchHighlightFocused(gsl::narrow<size_t>(idx), request.ScrollOffset);
_terminal->ScrollToSearchHighlight(request.ScrollOffset);
}
_renderer->TriggerSearchHighlight(oldResults);
}

int32_t totalMatches = 0;
Expand Down Expand Up @@ -1756,27 +1759,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
const auto lock = _terminal->LockForWriting();
_terminal->SetSearchHighlights({});
_terminal->SetSearchHighlightFocused({}, 0);
_terminal->SetSearchHighlightFocused(0);
_renderer->TriggerSearchHighlight(_searcher.Results());
_searcher = {};
}

// Method Description:
// - Tells ControlCore to snap the current search result index to currently
// selected text if the search was started using it.
void ControlCore::SnapSearchResultToSelection(bool shouldSnap) noexcept
{
_snapSearchResultToSelection = shouldSnap;
}

// Method Description:
// - Returns true, if we should snap the current search result index to
// the currently selected text after a new search is started, else false.
bool ControlCore::SnapSearchResultToSelection() const noexcept
{
return _snapSearchResultToSelection;
}

void ControlCore::Close()
{
if (!_IsClosing())
Expand Down Expand Up @@ -2221,19 +2208,32 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - <none>
void ControlCore::ClearBuffer(Control::ClearBufferType clearType)
{
if (clearType == Control::ClearBufferType::Scrollback || clearType == Control::ClearBufferType::All)
std::wstring_view command;
switch (clearType)
{
case ClearBufferType::Screen:
command = L"\x1b[H\x1b[2J";
break;
case ClearBufferType::Scrollback:
command = L"\x1b[3J";
break;
case ClearBufferType::All:
command = L"\x1b[H\x1b[2J\x1b[3J";
break;
}

{
const auto lock = _terminal->LockForWriting();
_terminal->EraseScrollback();
_terminal->Write(command);
}

if (clearType == Control::ClearBufferType::Screen || clearType == Control::ClearBufferType::All)
{
// Send a signal to conpty to clear the buffer.
if (auto conpty{ _connection.try_as<TerminalConnection::ConptyConnection>() })
{
// ConPTY will emit sequences to sync up our buffer with its new
// contents.
// Since the clearing of ConPTY occurs asynchronously, this call can result weird issues,
// where a console application still sees contents that we've already deleted, etc.
// The correct way would be for ConPTY to emit the appropriate CSI n J sequences.
conpty.ClearBuffer();
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/cascadia/TerminalControl/ControlCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
SearchResults Search(SearchRequest request);
const std::vector<til::point_span>& SearchResultRows() const noexcept;
void ClearSearch();
void SnapSearchResultToSelection(bool snap) noexcept;
bool SnapSearchResultToSelection() const noexcept;

void LeftClickOnTerminal(const til::point terminalPosition,
const int numberOfClicks,
Expand Down
3 changes: 1 addition & 2 deletions src/cascadia/TerminalControl/ControlCore.idl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Microsoft.Terminal.Control
Boolean GoForward;
Boolean CaseSensitive;
Boolean RegularExpression;
Boolean Reset;
Boolean ResetOnly;
Int32 ScrollOffset;
};

Expand Down Expand Up @@ -148,7 +148,6 @@ namespace Microsoft.Terminal.Control

SearchResults Search(SearchRequest request);
void ClearSearch();
Boolean SnapSearchResultToSelection;

Microsoft.Terminal.Core.Color ForegroundColor { get; };
Microsoft.Terminal.Core.Color BackgroundColor { get; };
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalControl/HwndTerminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,9 @@ void _stdcall TerminalSetTheme(void* terminal, TerminalTheme theme, LPCWSTR font
renderSettings.SetColorTableEntry(tableIndex, gsl::at(theme.ColorTable, tableIndex));
}

// Save these values as the new default render settings.
renderSettings.SaveDefaultSettings();

publicTerminal->_terminal->SetCursorStyle(static_cast<Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle>(theme.CursorStyle));

publicTerminal->_desiredFont = { fontFamily, 0, DEFAULT_FONT_WEIGHT, static_cast<float>(fontSize), CP_UTF8 };
Expand Down
Loading

0 comments on commit 053477d

Please sign in to comment.